結果
問題 |
No.644 G L C C D M
|
ユーザー |
![]() |
提出日時 | 2024-08-22 02:10:43 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 385 ms / 2,000 ms |
コード長 | 637 bytes |
コンパイル時間 | 453 ms |
コンパイル使用メモリ | 82,468 KB |
実行使用メモリ | 76,724 KB |
最終ジャッジ日時 | 2024-08-22 02:10:47 |
合計ジャッジ時間 | 3,476 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 |
ソースコード
from math import gcd,lcm N,M=map(int,input().split()) mod=10**9+7 # オイラーのトーシェント関数 import math def euler_totient(x): ANS=x # 素因数分解 L=int(math.sqrt(x)) FACT=dict() for i in range(2,L+2): while x%i==0: FACT[i]=FACT.get(i,0)+1 x=x//i if x!=1: FACT[x]=FACT.get(x,0)+1 # φ(x)=x(1-1/p_1)...(1-1/p_m)という性質を使って計算 for f in FACT: ANS=ANS*(f-1)//f return ANS score=0 for i in range(2,N//M+1): score+=euler_totient(i) ANS=score*2 for i in range(1,N-1): ANS=ANS*i%mod print(ANS)