반응형
#!/usr/bin/python
############################################################################
#
# Problem 48
# 18 July 2003
# 1 2 3 10
# The series, 1 + 2 + 3 + ... + 10 = 10405071317.
#
# Find the last ten digits of the series,
# 1 2 3 1000
# 1 + 2 + 3 + ... + 1000 .
############################################################################
# Author : DwYoon
# Date : 2007 04 12
def pow_mod(b, pw, md):
ret = 1
b = b % md
for i in range(pw):
ret = (ret*b) % md
return ret
def sum_mod(a, b, md):
return (a+b) % md
N = 1000
MOD = 10000000000 # last ten digit
res = 0
for i in range(1, N + 1):
res = sum_mod(res, pow_mod(i, i, MOD), MOD)
print(res)
728x90
'프로그래밍 > 알고리즘' 카테고리의 다른 글
[EP 080] 100까지의 정수의 제곱근의 자리수 합 (0) | 2020.11.17 |
---|---|
[파이썬] 이집트분수 (0) | 2020.04.23 |
[EP 050] 연속된소수의합이 다시 소수 (0) | 2019.12.18 |
[Euler Project 134] 1219는 소수 19로 끝나는 23의 배수 (3) | 2012.12.14 |
[Euler Project 089] 로마숫자 최적화 (0) | 2012.12.06 |