学习笔记

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

思路

这道题目就是一个数学题。

posted @ 2022-11-12 16:09  tommychen19  阅读(11)  评论(0)    收藏  举报