/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 43ms 18.641 MiB
#2 Accepted 53ms 18.777 MiB
#3 Time Exceeded ≥1102ms ≥18.535 MiB
#4 Time Exceeded ≥1003ms ≥18.57 MiB

Code

import sys
from itertools import *
from bisect import *
from collections import *
from math import gcd
import heapq

input = lambda: sys.stdin.readline().rstrip("\r\n")
rint = lambda: int(input())
rlist = lambda: list(map(int, input().split()))
rgrid = lambda n: [rlist() for _ in range(n)]

fmin = lambda x, y: x if x < y else y
fmax = lambda x, y: x if x > y else y
# MOD = 998244353
MOD = 10**9 + 7
INF = float("inf")


def solve():
    N = rint()
    r = 0
    i = 1
    while i <= N:
        q = N // i
        j = N // q
        r += q * (j - i + 1)
        i = j + 1
    return r - N


TT = 1
TT = rint()
for tc in range(TT):
    ans = solve()

    print(ans)
    # print(*ans)
    # print("Yes" if ans else "No")

Information

Submit By
Type
Submission
Problem
P1207 D2. GCD equal Absolute Value (Hard Version)
Contest
Educational Round 1
Language
PyPy 3 (Python 3.9.18 PyPy 7.3.15)
Submit At
2025-07-14 15:47:32
Judged At
2025-07-14 15:47:32
Judged By
Score
5
Total Time
≥1102ms
Peak Memory
≥18.777 MiB