欢乐赛#40 T2 题解
2025-02-11 20:30:38
发布于:河北
9阅读
0回复
0点赞
首先,直接pow(114514,n)计算114514的n次方时间过大,所以要转换成周期问题来计算,根据伟大的计算器,可以得出以下结论:
但是,看尾数就行了,得出结论:奇数为4,偶数为6
因此,使用for循环套用即可(三目运算符 or if else)
#include<iostream>
using namespace std;
int main(){
int n,x;//这里直接设立变量X,而不在循环里生成是因为会多占用亿点空间(
cin>>n;
for(int i=0;i<n;i++){
cin>>x;
cout << (x % 2 ? 4 : 6) << '\n';//判断+换行
}
return 0;
}
这里空空如也
有帮助,赞一个