結果
| 問題 |
No.1022 Power Equation
|
| コンテスト | |
| ユーザー |
tamato
|
| 提出日時 | 2020-04-10 23:15:04 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 863 bytes |
| コンパイル時間 | 195 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 80,896 KB |
| 最終ジャッジ日時 | 2024-09-16 00:15:05 |
| 合計ジャッジ時間 | 2,132 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 7 WA * 1 |
ソースコード
def main():
import sys
from math import log, gcd, floor
input = sys.stdin.buffer.readline
div = [set() for _ in range(41)]
for i in range(1, 41):
for j in range(2, 41):
if i%j==0:
div[i].add(j)
for _ in range(int(input())):
N = int(input())
ans = 0
sqrtN = int(N**0.5)
seen = [0] * (sqrtN + 1)
for a in range(2, sqrtN+1):
if seen[a]:
continue
L = floor(log(N, a))
for i in range(1, L+1):
if a**i <= sqrtN:
seen[a**i] = 1
for j in range(i+1, L+1):
g = gcd(i, j)
ans += N // (j // g)
ans *= 2
ans += N**2 # b==d
ans += N**2-N # a==c==1
print(ans)
if __name__ == '__main__':
main()
tamato