现在的位置: 首页 > 综合 > 正文

FZU 1053 Happy 2004

2013年10月04日 ⁄ 综合 ⁄ 共 1010字 ⁄ 字号 评论关闭

 

Happy 2004


Time Limit:1s Memory limit:32M
Accepted Submit:142 Total Submit:279

Consider a positive integer X,and let S be the sum of all positive integer divisors of 2004X. Your job is to determine S modulo 29 (the rest of the division of S by 29).

Take X = 1 for an example. The positive integer divisors of 20041 are 1, 2, 3, 4, 6, 12, 167, 334, 501, 668, 1002 and 2004. Therefore S = 4704 and S modulo 29 is equal to 6.

Input

The input consists of several test cases. Each test case contains a line with the integer X (1 <= X <= 10000000).
A test case of X = 0 indicates the end of input, and should not be processed.

Output

For each test case, in a separate line, please output the result of S modulo 29.

Sample Input

1
10000
0

Output for the Sample Input

6
10

Original: 2004 ACM/ICPC Beijing Practice Problem

 

解题:

       运用到欧拉定理,费马小定理。要求某个数A的所有因子和,首先将该数分解:

 

先贴代码

抱歉!评论已关闭.