結果

問題 No.1918 Simple Math ?
ユーザー googol_S0googol_S0
提出日時 2022-04-29 21:47:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 801 ms / 2,000 ms
コード長 427 bytes
コンパイル時間 520 ms
コンパイル使用メモリ 87,168 KB
実行使用メモリ 154,388 KB
最終ジャッジ日時 2023-09-11 12:46:00
合計ジャッジ時間 12,821 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
83,780 KB
testcase_01 AC 80 ms
76,240 KB
testcase_02 AC 81 ms
76,140 KB
testcase_03 AC 80 ms
75,964 KB
testcase_04 AC 82 ms
75,924 KB
testcase_05 AC 83 ms
75,924 KB
testcase_06 AC 136 ms
84,032 KB
testcase_07 AC 200 ms
87,980 KB
testcase_08 AC 138 ms
81,992 KB
testcase_09 AC 103 ms
78,864 KB
testcase_10 AC 133 ms
83,896 KB
testcase_11 AC 84 ms
76,496 KB
testcase_12 AC 159 ms
87,032 KB
testcase_13 AC 123 ms
82,828 KB
testcase_14 AC 108 ms
80,376 KB
testcase_15 AC 90 ms
77,556 KB
testcase_16 AC 332 ms
109,628 KB
testcase_17 AC 351 ms
112,256 KB
testcase_18 AC 505 ms
125,488 KB
testcase_19 AC 506 ms
128,736 KB
testcase_20 AC 403 ms
119,656 KB
testcase_21 AC 751 ms
150,784 KB
testcase_22 AC 801 ms
149,980 KB
testcase_23 AC 782 ms
149,852 KB
testcase_24 AC 765 ms
149,576 KB
testcase_25 AC 720 ms
150,272 KB
testcase_26 AC 711 ms
154,388 KB
testcase_27 AC 751 ms
154,172 KB
testcase_28 AC 398 ms
121,940 KB
testcase_29 AC 73 ms
71,264 KB
testcase_30 AC 74 ms
71,388 KB
testcase_31 AC 642 ms
154,256 KB
testcase_32 AC 81 ms
76,188 KB
testcase_33 AC 79 ms
75,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod=10**9+7
def solve():
  A,N=map(int,input().split())
  C=[0]*A
  M=A*N
  R=0
  for i in range(31,-1,-1):
    v=R+(1<<i)
    if v*v<=M:
      R=v
  V=0
  for k in range(1,A+1):
    v=(R+A-k)//A
    C[(k*k-1)%A]+=v
  for i in range(A):
    C[i]%=mod
    V=(V+i*C[i])%mod
  W=R*(R+1)*(2*R+1)//6
  W=(W-R)%mod
  W=(W-V)%mod
  W=W*pow(A,mod-2,mod)%mod
  #print(R,N,W)
  print((R*N-W)%mod)

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