#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int a , b ,s;
while ( cin >> a >> b )
{
s = pow(a,1);
s = s%10007;
for(int i = 1 ; i<b ; i+=1)
{
s= s *a ;
s = s % 10007;
}
cout << s << endl;
}
return 0;
}
第3點TLE 有人可以跟我說哪裡需要改嗎 或是有更~讚的方法:D
#include
#include
using namespace std;
int main()
{
int a , b ,s;
while ( cin >> a >> b )
{
s = pow(a,1);
s = s%10007;
for(int i = 1 ; i {
s= s *a ;
s = s % 10007;
}
cout << s << endl;
}
return 0;
}
第3點TLE 有人可以跟我說哪裡需要改嗎 或是有更~讚的方法:D
打 65535 2147483647
會跑到想哭的
用快速 冪取模