whytree

导航

 

方法一:取模

:求1992的n次方的末两位数字

#include<iostream>
using namespace std;
int main()
{
	int a=1,t=0,n;
	cin>>n;
	do
	{
		++t;
		a=(a*92)%100;//注意本题只能进行取模运算,因为结果数值过大必定溢出 
	}
	while(t<n);
	cout<<a<<endl;
	return 0;
}

对于这种题目,最好一开始就取模,不然在运算过程中可能就会发生数据的溢出

posted on 2026-01-18 20:44  why_tree  阅读(0)  评论(0)    收藏  举报