結果
| 問題 | No.2249 GCDistance |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-03-17 23:38:22 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 360 bytes |
| 記録 | |
| コンパイル時間 | 775 ms |
| コンパイル使用メモリ | 85,504 KB |
| 実行使用メモリ | 630,144 KB |
| 最終ジャッジ日時 | 2026-04-06 16:37:34 |
| 合計ジャッジ時間 | 16,477 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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()