結果
| 問題 |
No.2249 GCDistance
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-03-17 23:38:22 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 360 bytes |
| コンパイル時間 | 232 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 547,444 KB |
| 最終ジャッジ日時 | 2024-09-18 12:36:41 |
| 合計ジャッジ時間 | 33,297 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | MLE * 1 |
| other | MLE * 10 |
ソースコード
# calculate φ(x) for 1 <= x <= M
M = 10**7+10
*phi, = range(M+1)
for x in range(2, M+1):
if phi[x] == x:
for y in range(x, M+1, x):
phi[y] = phi[y] // x * (x-1)
for i in range(1,M+1):
phi[i] += phi[i-1]
def sol():
n = int(input())
ans = (-phi[n] + 1) + n*(n-1)
print(ans)
t = int(input())
for i in range(t):
sol()