結果
| 問題 |
No.2703 FizzBuzz Letter Counting
|
| コンテスト | |
| ユーザー |
PNJ
|
| 提出日時 | 2024-03-29 23:01:23 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 432 ms / 3,000 ms |
| コード長 | 1,403 bytes |
| コンパイル時間 | 189 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 76,544 KB |
| 最終ジャッジ日時 | 2024-09-30 16:46:16 |
| 合計ジャッジ時間 | 16,234 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 60 |
ソースコード
mod = 998244353
Nmod3 = 0
Nmod5 = 0
Nmod15 = 0
N = 0
D = 0
M = int(input())
nine = pow(9,-1,mod)
F = {1:1,2:11,0:6}
for i in range(M):
v,l = map(int,input().split())
# N
N *= pow(10,l,mod)
N %= mod
res = pow(10,l,mod) - 1
res %= mod
res *= nine
res %= mod
res *= v
res %= mod
N += res
N %= mod
# D
D += l
# Nmod3
Nmod3 += v*(l%3)
Nmod3 %= 3
#Nmod5
Nmod5 = v % 5
#Nmod15
Nmod15 *= pow(10,l,15)
Nmod15 %= 15
Nmod15 += F[l%3]*v
Nmod15 %= 15
if D == 1:
ans = 0
for i in range(1,N+1):
if i % 3 == 0:
ans += 4
elif i % 5 == 0:
ans += 4
else:
ans += 1
print(ans)
exit()
ans = 0
# 2 ~ D - 1桁目まで
if D > 2:
res = pow(10,D-2,mod) - 1
res *= nine
res %= mod
res %= mod
res *= 6
res %= mod
ans += res
res = pow(10,D,mod) * D
res %= mod
res *= 9
res %= mod
f = pow(10,D,mod)*7 - 250
f %= mod
f *= 4
f %= mod
res -= f
res %= mod
res *= pow(8100,-1,mod)
res %= mod
ans += res
ans %= mod
ans *= 48
ans %= mod
# 1桁目
if D > 1:
ans += 21
ans %= mod
# D桁目
c3 = 0
c5 = 0
c15 = 0
N -= pow(10,D-1,mod)
N %= mod
D %= mod
c3 = (N - 1 + 2 - Nmod3) * pow(3,-1,mod)
c3 %= mod
c5 = 1 + (N - Nmod5) * pow(5,-1,mod)
c5 %= mod
c15 = (N - 4 + 14 - Nmod15) * pow(15,-1,mod)
c15 %= mod
N -= (c3 + c5 - c15) - 1
N %= mod
ans += D*N
ans %= mod
ans += 4*(c3 + c5)
ans %= mod
print(ans)
PNJ