學(xué)習(xí)筆記
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
思路
這道題目就是一個數(shù)學(xué)題。

浙公網(wǎng)安備 33010602011771號