結果
| 問題 |
No.2829 GCD Divination
|
| コンテスト | |
| ユーザー |
ぬるぽ
|
| 提出日時 | 2024-08-02 22:05:33 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,068 bytes |
| コンパイル時間 | 231 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 19,488 KB |
| 最終ジャッジ日時 | 2024-08-02 22:05:37 |
| 合計ジャッジ時間 | 3,787 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 TLE * 1 -- * 32 |
ソースコード
from copy import deepcopy, copy
import sys
import io
from typing import Optional
import time
from random import randrange, randint, random, uniform
import sys, io
from collections import deque, defaultdict
import heapq
from collections import Counter
import math
from math import gcd
from functools import lru_cache
from itertools import combinations, permutations
from bisect import bisect_left, bisect_right
from itertools import groupby
from itertools import accumulate
from math import factorial
import decimal
import math
# from sortedcontainers import SortedList
# import pypyjit
# pypyjit.set_param("max_unroll_recursion=-1")
sys.setrecursionlimit(1000000000)
sys.set_int_max_str_digits(1000000000)
start_time = time.time()
N = int(input())
@lru_cache(maxsize=None)
def rec(n):
if n == 1:
return 0
num = 0
cnt = 0
for M in range(1, N + 1):
if gcd(n, M) == n:
cnt += 1
continue
num += rec(gcd(n, M))
num += N
# print(n, cnt)
return num * 1 / (N - cnt)
print(rec(N))
ぬるぽ