結果

問題 No.2649 [Cherry 6th Tune C] Anthem Flower
ユーザー ゼットゼット
提出日時 2024-02-23 21:49:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 762 bytes
コンパイル時間 131 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 82,928 KB
最終ジャッジ日時 2024-02-23 21:50:07
合計ジャッジ時間 10,985 ms
ジャッジサーバーID
(参考情報)
judge12 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 874 ms
77,504 KB
testcase_02 AC 815 ms
76,888 KB
testcase_03 AC 861 ms
77,444 KB
testcase_04 AC 849 ms
77,764 KB
testcase_05 AC 1,065 ms
77,228 KB
testcase_06 AC 985 ms
77,024 KB
testcase_07 AC 176 ms
77,220 KB
testcase_08 AC 174 ms
77,328 KB
testcase_09 AC 120 ms
76,560 KB
testcase_10 AC 119 ms
76,560 KB
testcase_11 AC 46 ms
62,116 KB
testcase_12 AC 46 ms
62,112 KB
testcase_13 AC 90 ms
80,980 KB
testcase_14 AC 76 ms
79,320 KB
testcase_15 AC 95 ms
79,180 KB
testcase_16 AC 90 ms
80,912 KB
testcase_17 AC 91 ms
81,820 KB
testcase_18 AC 101 ms
81,356 KB
testcase_19 AC 95 ms
81,240 KB
testcase_20 AC 79 ms
82,916 KB
testcase_21 AC 100 ms
81,272 KB
testcase_22 AC 100 ms
82,620 KB
testcase_23 AC 57 ms
77,556 KB
testcase_24 AC 56 ms
77,556 KB
testcase_25 AC 76 ms
82,928 KB
testcase_26 AC 56 ms
77,556 KB
testcase_27 AC 80 ms
82,928 KB
testcase_28 AC 74 ms
82,928 KB
testcase_29 AC 75 ms
82,928 KB
testcase_30 AC 58 ms
77,556 KB
testcase_31 AC 76 ms
82,928 KB
testcase_32 AC 75 ms
82,928 KB
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

Q=int(input())
for _ in range(Q):
  S,M=input().split()
  M=int(M)
  N=len(S)
  u=[1]*N
  mod=M
  if M==1:
    print(0)
    continue
  for i in range(1,N):
    u[i]=u[i-1]*10
    u[i]%=mod
  x=0
  for i in range(N):
    x+=int(S[-(i+1)])*u[i]
    x%=mod
  if M%2==1:
    result=x*(x+1)
    result%=mod
    result*=pow(2,-1,mod)
    result%=mod
    print(result)
  else:
    result=x*(x+1)//2
    result%=mod
    u2=[1]*N
    mod2=2*M
    for i in range(1,N):
      u2[i]=u2[i-1]*10
      u2[i]%=mod2
    z=0
    for i in range(N):
      z+=int(S[-(i+1)])*u2[i]
      z%=mod2
    if x%2==0:
      if z!=x:
        result+=(M//2)*(x+1)
        result%=mod
    else:
      if ((z+1)%mod2)!=((x+1)%mod):
        result+=(M//2)*x
        result%=mod
    print(result)
0