結果
| 問題 | No.2249 GCDistance | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-03-17 23:40:52 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                MLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 360 bytes | 
| コンパイル時間 | 329 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 815,232 KB | 
| 最終ジャッジ日時 | 2024-09-18 12:37:02 | 
| 合計ジャッジ時間 | 13,232 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | MLE * 1 | 
| other | -- * 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()
            
            
            
        