学习笔记
2022 CSP-J
T1
思路
非常简单的一道题。只需要不断地 \(\times 2\),当答案超过 \(10^9\) 时跳出即可。
代码
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int a,b;
cin>>a>>b;
int x=1;
if(a==1){
cout<<1<<endl;
return 0;
}
for(int i=1;i<=b;i++){
x*=a;
if(x>1e9){
cout<<"-1"<<endl;
return 0;
}
}
cout<<x<<endl;
return 0;
}
T2
思路
这道题目就是一个数学题。

浙公网安备 33010602011771号