結果
| 問題 |
No.2249 GCDistance
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-03-17 23:24:58 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 718 bytes |
| コンパイル時間 | 223 ms |
| コンパイル使用メモリ | 81,924 KB |
| 実行使用メモリ | 626,192 KB |
| 最終ジャッジ日時 | 2024-09-18 12:28:24 |
| 合計ジャッジ時間 | 29,922 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | MLE * 1 |
| other | MLE * 10 |
ソースコード
from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline
# calculate φ(x) for 1 <= x <= M
class euler_phi():
def __init__(self,M=10**7):
*self.phi, = range(M+1)
for x in range(2, M+1):
if self.phi[x] == x:
for y in range(x, M+1, x):
self.phi[y] = self.phi[y] // x * (x-1)
M = 10**7
ep = euler_phi(M)
S = [0]*(M+1)
S[1] = 0
for i in range(1,M):
S[i+1] = S[i] + ep.phi[i+1] + (i - ep.phi[i+1])*2
def answer():
N = int(input())
print(S[N])
for _ in range(int(input())):
answer()