結果

問題 No.1918 Simple Math ?
ユーザー kozykozy
提出日時 2022-04-30 00:59:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 803 bytes
コンパイル時間 549 ms
コンパイル使用メモリ 86,980 KB
実行使用メモリ 149,472 KB
最終ジャッジ日時 2023-09-11 16:52:28
合計ジャッジ時間 19,268 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 427 ms
84,608 KB
testcase_01 AC 114 ms
77,656 KB
testcase_02 AC 102 ms
76,604 KB
testcase_03 AC 122 ms
77,768 KB
testcase_04 AC 111 ms
77,300 KB
testcase_05 AC 119 ms
77,472 KB
testcase_06 AC 184 ms
77,340 KB
testcase_07 AC 180 ms
78,484 KB
testcase_08 AC 121 ms
77,492 KB
testcase_09 AC 147 ms
77,728 KB
testcase_10 AC 297 ms
81,512 KB
testcase_11 AC 115 ms
77,212 KB
testcase_12 AC 371 ms
83,288 KB
testcase_13 AC 406 ms
84,244 KB
testcase_14 AC 102 ms
76,540 KB
testcase_15 AC 138 ms
77,728 KB
testcase_16 WA -
testcase_17 AC 1,737 ms
113,820 KB
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(n):
  a=int(n**0.5)
  return a
T=int(input())
mod=10**9+7
for _ in range(T):
  a,N=map(int,input().split())
  ans=0
  for i in range(1,a):
    if i>N:
      break
    ans+=f(a*i)
    ans%=mod
  if a-1>=N:
    print(ans)
    continue
  K=[0]*a
  s1=0
  for i in range(a,4*a):
    s=f(i*a)
    K[s-a]+=1
    s1+=s
  x=f(N//a)
  #x>=1
  s1%=mod
  s2=((3*a-1)*a//2)%mod
  s3=3*a
  kosu=a
  if x>=2:
    ans+=s1*(x-1)%mod
    ans+=(a*kosu%mod*((x-2)*(x-1)*(2*x-3))//3)%mod
    ans+=(((x-2)*(x-1))//2)*a%mod*s3%mod
    ans+=(x-2)*(x-1)*s2%mod
    ans%=mod
  #(x**2)*a~N
  kk=N-((x**2)*a)+1
  for i in range(a):
    if kk-(K[i]+2*(x-1))<=0:
      ans+=kk*(i+a*x)
      ans%=mod
      break
    else:
      kk-=(K[i]+2*(x-1))
      kk%=mod
      ans+=(i+a*x)*(K[i]+2*(x-1))%mod
      ans%=mod
  print(ans)
0