hdu 1211 数论

hdu 1211 数论
1 #include  < stdio.h >
 2 #include  < stdlib.h >
 3 #include  < math.h >
 4 int  main ()
 5 {
 6    int p, q, e, l;
 7    __int64 n, Fn;
 8    int d;
 9    
10    while ( scanf ("%d%d%d%d"&p, &q, &e, &l) != EOF )
11    {
12          n = p * q;
13          Fn = (p -1* (q - 1);
14          //利用枚举法求d
15          d = 1;
16          while ( (d * e) % Fn != 1)
17          d ++
18           
19           //破译密文:利用scanf输入空格结束处理c
20           int c, temp;
21           for (int i = 0; i < l; i++)
22           {
23               scanf("%d"&c); 
24               temp = 1;
25               for (int j = 1; j <= d; j++)  //难点:如何利用数论知识处理计算 (c 的 d 次方) %  n;
26                                             //上式等于  (c %  n) d 次方  % n; 
27               {
28                   temp *= c;
29                   temp %= n;
30               }
  
31               printf ("%c",temp);                                                                                                                                                                                                                                                                                                                                      
32           }
 
33           
34           printf ("\n");
35    }

36    return 0;
37}

38

你可能感兴趣的:(hdu 1211 数论)