• 欢迎光临~

# 第一题

``````#include <bits/stdc++.h>
using namespace std;
string sa;
long long a,b,c=1;
int main(){
freopen("pow.in","r",stdin);
freopen("pow.out","w",stdout);
cin>>sa>>b;
int len=sa.length();
if(len>9){
cout<<-1;
return 0;
}
for(int i=1;i<=len;i++){
a=a+sa[i-1]-'0';
if(i!=len) a=a*10;
}
if(a>1e9){
cout<<-1;
return 0;
}
for(int i=1;i<=b;i++){
if(c*a>1e9){
cout<<-1;
return 0;
}
c*=a;
}
cout<<c;
return 0;
}
``````

# 第二题

``````#include <bits/stdc++.h>
using namespace std;
int k;
long long n,e,d,h;
bool flag;
int main(){
freopen("decode.in","r",stdin);
freopen("decode.out","w",stdout);
cin>>k;
while(k--){
cin>>n>>d>>e;
flag=0;
h=e*d-1;
for(int i=1;i<=sqrt(n);i++){
if(n%i!=0) continue;
long long p=i,q=n/p;
if((p-1)*(q-1)==h){
cout<<p<<" "<<q<<endl;
flag=1;
break;
}
}
if(flag==0){
cout<<"NO"<<endl;
}
}
return 0;
}
``````

# 第三题

1. 先将括号内的式子单独拿出计算，将结果返回
2. 计算`&`
3. 计算`|`

``````#include <bits/stdc++.h>
using namespace std;
string s;
int a,b;
int suan(string s){
if(s.length()==3){
if(s[1]=='&'){
if(s[0]=='0'){
a++;
return 0;
}else return (s[0]-'0')&(s[2]-'0');
}else{
if(s[0]=='1'){
b++;
return 1;
}else{
return (s[0]-'0')|(s[2]-'0');
}
}
}
int ff=0;
stringstream sa;
string aa;
int last;
for(int i=0;i<s.length();i++){
if(s[i]=='('&&ff==0) last=i;
if(s[i]=='(') ff++;
else if(s[i]==')'){
ff--;
if(ff==0){
stringstream c;
for(int j=last+1;j<i;j++){
c<<s[j];
}
string sc;
c>>sc;
sa<<suan(sc);
}
}else if(ff==0){
sa<<s[i];
}
}
sa>>aa;
sa.clear();
ff=-1;
for(int i=0;i<aa.length();i++){
if(aa[i]=='|'){
if(aa[i-1]!='&') sa<<aa[i-1]<<aa[i];
else sa<<aa[i];
}
if(aa[i]=='&'){
stringstream c;
if(ff==-1){
c<<aa[i-1]<<aa[i]<<aa[i+1];
}else{
c<<ff<<aa[i]<<aa[i+1];
}
string sc;
c>>sc;
// sa<<suan(sc);
if(aa[i+2]=='&'){
ff=suan(sc);
}else{
ff=-1;
sa<<suan(sc);
}
}
}
sa>>aa;
sa.clear();
ff=-1;
for(int i=0;i<aa.length();i++){
if(aa[i]=='|'){
stringstream c;
if(ff==-1){
c<<aa[i-1]<<aa[i]<<aa[i+1];
}else{
c<<ff<<aa[i]<<aa[i+1];
}
string sc;
c>>sc;
// sa<<suan(sc);
if(aa[i+2]=='|'){
ff=suan(sc);
}else{
ff=-1;
sa<<suan(sc);
}
}
}
sa>>aa;
if(aa[0]=='0'){
return 0;
}else{
return 1;
}
return 0;
}
int main(){
freopen("expr.in","r",stdin);
freopen("expr.out","w",stdout);
cin>>s;
cout<<suan(s)<<endl;
cout<<a<<" "<<b;
return 0;
}
``````

# 大总结

• 时间分配有问题
• 对数学题没有清晰判断

## 解决方法

• 先读一遍所有题，又较清晰的理解后再开始写
• 注意时间分配