結果
| 問題 | No.1164 GCD Products hard |
| ユーザー |
ayaoni
|
| 提出日時 | 2020-12-10 01:44:18 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 1,007 ms / 2,500 ms |
| コード長 | 1,163 bytes |
| 記録 | |
| コンパイル時間 | 141 ms |
| コンパイル使用メモリ | 82,508 KB |
| 実行使用メモリ | 188,760 KB |
| 最終ジャッジ日時 | 2024-09-19 08:10:53 |
| 合計ジャッジ時間 | 17,146 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 27 |
ソースコード
import sys
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())
def sieve_of_eratosthenes(n): # n以下の素数の全列挙
prime_list = []
is_prime = [1]*(n+1) # A[i] = iが素数なら1,その他は0
is_prime[0] = is_prime[1] = 0
for i in range(2,int(n**.5)+1):
if is_prime[i]:
prime_list.append(i)
for j in range(i**2,n+1,i):
is_prime[j] = 0
for i in range(int(n**.5)+1,n+1):
if is_prime[i] == 1:
prime_list.append(i)
return prime_list
A,B,N = MI()
mod = 10**9+7
prime_list = sieve_of_eratosthenes(B)
ans = 1
for p in prime_list:
a = 0
x = p
while x <= B:
a += pow(B//x-(A-1)//x,N,mod-1)
x *= p
ans *= pow(p,a,mod)
ans %= mod
print(ans)
ayaoni