#5569: 欸嘿


qqqaaa830107 (ALEX)

學校 : 國立臺灣科技大學
編號 : 16015
來源 : [140.118.233.95]
最後登入時間 :
2014-06-11 00:03:43
. Unfinished! | From: [203.71.186.182] | 發表日期 : 2011-08-12 17:56


#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

 
#5570: Re:欸嘿


grd (保持好奇心)

學校 : 臺中市私立明道高級中學
編號 : 18826
來源 : [140.113.207.250]
最後登入時間 :
2019-01-21 21:20:44
. Unfinished! | From: [114.38.55.102] | 發表日期 : 2011-08-12 21:43


#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
會跑到想哭的

 

用快速 冪取模

 
ZeroJudge Forum