結果

問題 No.1022 Power Equation
ユーザー hedwig100hedwig100
提出日時 2020-04-11 16:09:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 720 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 11,928 KB
実行使用メモリ 10,308 KB
最終ジャッジ日時 2023-10-19 07:39:03
合計ジャッジ時間 1,544 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
10,308 KB
testcase_01 AC 90 ms
10,308 KB
testcase_02 AC 89 ms
10,308 KB
testcase_03 AC 85 ms
10,308 KB
testcase_04 AC 87 ms
10,308 KB
testcase_05 AC 88 ms
10,308 KB
testcase_06 AC 93 ms
10,308 KB
testcase_07 AC 87 ms
10,308 KB
testcase_08 AC 91 ms
10,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from math import gcd

def root_int(a,k):
    if k == 0:
        return 0
    x = int(a ** (1 / k))
    while (x ** k) > a:
        x -= 1
    while ((x + 1) ** k) <= a:
        x += 1
    return x

def main():
    t = int(input())
    for _ in range(t):
        n = int(input())
        ans = n * n
        for b in range(1,35):
            for d in range(1,35):
                if gcd(b,d) != 1:
                    continue
                lim1 = max(root_int(n,max(b,d)),1) - 1
                lim2 = n//max(b,d)
                ans += lim1 * lim2
        print(ans)

if __name__ =='__main__':
    main()   
0