結果

問題 No.1918 Simple Math ?
ユーザー kozykozy
提出日時 2022-04-30 01:09:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,292 ms / 2,000 ms
コード長 861 bytes
コンパイル時間 435 ms
コンパイル使用メモリ 86,936 KB
実行使用メモリ 155,272 KB
最終ジャッジ日時 2023-09-11 17:03:50
合計ジャッジ時間 18,770 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 200 ms
84,748 KB
testcase_01 AC 103 ms
77,576 KB
testcase_02 AC 98 ms
76,856 KB
testcase_03 AC 111 ms
77,488 KB
testcase_04 AC 104 ms
77,264 KB
testcase_05 AC 106 ms
77,316 KB
testcase_06 AC 160 ms
77,168 KB
testcase_07 AC 131 ms
78,612 KB
testcase_08 AC 96 ms
77,360 KB
testcase_09 AC 107 ms
77,808 KB
testcase_10 AC 165 ms
81,000 KB
testcase_11 AC 93 ms
77,132 KB
testcase_12 AC 192 ms
83,204 KB
testcase_13 AC 203 ms
83,444 KB
testcase_14 AC 91 ms
76,820 KB
testcase_15 AC 108 ms
77,444 KB
testcase_16 AC 632 ms
111,128 KB
testcase_17 AC 671 ms
113,892 KB
testcase_18 AC 890 ms
126,700 KB
testcase_19 AC 925 ms
130,112 KB
testcase_20 AC 793 ms
121,012 KB
testcase_21 AC 1,277 ms
152,252 KB
testcase_22 AC 1,267 ms
151,576 KB
testcase_23 AC 1,268 ms
150,984 KB
testcase_24 AC 1,273 ms
151,068 KB
testcase_25 AC 1,260 ms
151,680 KB
testcase_26 AC 1,148 ms
155,068 KB
testcase_27 AC 1,266 ms
154,980 KB
testcase_28 AC 73 ms
71,560 KB
testcase_29 AC 74 ms
71,472 KB
testcase_30 AC 74 ms
71,524 KB
testcase_31 AC 1,292 ms
155,272 KB
testcase_32 AC 89 ms
76,444 KB
testcase_33 AC 89 ms
76,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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+=int((a*i)**0.5)
    ans%=mod
  if a-1>=N:
    print(ans)
    continue
  K=[0]*a
  s1=0
  for i in range(a,2*a):
    #i**2以上(i+1)**2未満のaの倍数の個数
    K[i-a]=(((i+1)**2-1)//a)-((i**2-1)//a)
    s1+=K[i-a]*i
    s1%=mod
  x=int((N//a)**0.5)
  #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
  t=a*x
  for i in range(a):
    if kk-(K[i]+2*(x-1))<=0:
      ans+=kk*(i+t)
      ans%=mod
      break
    else:
      kk-=(K[i]+2*(x-1))
      ans+=(i+t)*(K[i]+2*(x-1))%mod
      ans%=mod
  print(ans)
0