結果

問題 No.2262 Fractions
ユーザー とりゐとりゐ
提出日時 2023-03-10 18:42:36
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 774 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 82,836 KB
実行使用メモリ 167,380 KB
最終ジャッジ日時 2024-04-10 02:01:25
合計ジャッジ時間 29,296 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 539 ms
117,808 KB
testcase_01 AC 399 ms
77,604 KB
testcase_02 AC 374 ms
77,760 KB
testcase_03 AC 421 ms
77,328 KB
testcase_04 AC 388 ms
77,708 KB
testcase_05 AC 433 ms
77,612 KB
testcase_06 AC 357 ms
77,164 KB
testcase_07 AC 381 ms
77,584 KB
testcase_08 AC 433 ms
77,424 KB
testcase_09 AC 398 ms
77,440 KB
testcase_10 AC 355 ms
77,068 KB
testcase_11 AC 635 ms
78,684 KB
testcase_12 AC 608 ms
78,528 KB
testcase_13 AC 613 ms
78,284 KB
testcase_14 AC 616 ms
78,392 KB
testcase_15 AC 607 ms
78,360 KB
testcase_16 AC 181 ms
76,508 KB
testcase_17 AC 183 ms
76,576 KB
testcase_18 AC 182 ms
76,820 KB
testcase_19 AC 773 ms
126,724 KB
testcase_20 AC 720 ms
121,124 KB
testcase_21 AC 763 ms
128,960 KB
testcase_22 AC 717 ms
120,596 KB
testcase_23 AC 619 ms
108,924 KB
testcase_24 AC 729 ms
165,376 KB
testcase_25 AC 823 ms
166,924 KB
testcase_26 AC 820 ms
165,332 KB
testcase_27 AC 828 ms
165,624 KB
testcase_28 AC 813 ms
164,332 KB
testcase_29 AC 845 ms
167,380 KB
testcase_30 AC 835 ms
167,080 KB
testcase_31 AC 817 ms
167,204 KB
testcase_32 AC 782 ms
166,872 KB
testcase_33 AC 835 ms
166,728 KB
testcase_34 AC 841 ms
166,860 KB
testcase_35 AC 414 ms
166,980 KB
testcase_36 AC 412 ms
166,644 KB
testcase_37 AC 73 ms
77,816 KB
testcase_38 AC 73 ms
78,020 KB
testcase_39 AC 722 ms
124,004 KB
testcase_40 AC 755 ms
123,744 KB
testcase_41 AC 775 ms
123,824 KB
testcase_42 AC 773 ms
123,884 KB
testcase_43 AC 722 ms
123,492 KB
testcase_44 WA -
testcase_45 AC 823 ms
166,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin
input=lambda :stdin.readline()[:-1]

def calc(n,p):
  dp=[0]*(n+1)
  for i in range(1,n+1):
    s=p*i//m
    dp[i]+=s
    if dp[i]==0:
      continue
    for j in range(2*i,n+1,i):
      dp[j]-=dp[i]
  return sum(dp)

m=1<<38
def solve():
  n,k=map(int,input().split())
  c=calc(n,m-1)
  if k==c+1:
    print('1/1')
    return
  if k<=c:
    rev=False
  elif k<=2*c+1:
    rev=True
    k=2*c+2-k
  else:
    print(-1)
    return
  ng,ok=0,1<<40
  for _ in range(38):
    mid=(ok+ng)//2
    if calc(n,mid)>=k:
      ok=mid
    else:
      ng=mid
  
  ans=-1
  for p in range(1,n+1):
    q=(ok*p)//m
    if m*q>ng*p:
      if rev:
        p,q=q,p
      print(str(q)+'/'+str(p))
      return
    
  raise Exception

for _ in range(int(input())):
  solve()
0