Why?求助
查看原帖
Why?求助
399457
蜗牛与飞猪楼主2023/8/27 14:47

最后一行为什么只能用printf,用cout直接爆0???

#include<bits/stdc++.h>
using namespace std;

long long a,b,p;

int main()
{
	ios::sync_with_stdio(0);
	cin>>a>>b>>p;
	
	long long ans=1;
	printf("%lld^%lld mod %lld=",a,b,p);
	
	if(b==0)
	{
		cout<<1<<endl;
		return 0;
	}
	while(b>0)
	{
		if(b%2==1)ans=ans*a%p;
		b/=2;
		a=a*a%p;
	}
	ans%=p;
	cout<<ans<<endl;
	
	return 0;
}
2023/8/27 14:47
加载中...