結果

問題 No.2703 FizzBuzz Letter Counting
ユーザー kotatsugamekotatsugame
提出日時 2024-03-29 23:01:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 58 ms / 3,000 ms
コード長 1,044 bytes
コンパイル時間 744 ms
コンパイル使用メモリ 70,332 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-03-29 23:01:18
合計ジャッジ時間 4,946 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 51 ms
6,548 KB
testcase_04 AC 9 ms
6,548 KB
testcase_05 AC 9 ms
6,548 KB
testcase_06 AC 23 ms
6,548 KB
testcase_07 AC 40 ms
6,548 KB
testcase_08 AC 5 ms
6,548 KB
testcase_09 AC 45 ms
6,548 KB
testcase_10 AC 24 ms
6,548 KB
testcase_11 AC 4 ms
6,548 KB
testcase_12 AC 32 ms
6,548 KB
testcase_13 AC 13 ms
6,548 KB
testcase_14 AC 52 ms
6,548 KB
testcase_15 AC 50 ms
6,548 KB
testcase_16 AC 48 ms
6,548 KB
testcase_17 AC 7 ms
6,548 KB
testcase_18 AC 37 ms
6,548 KB
testcase_19 AC 30 ms
6,548 KB
testcase_20 AC 36 ms
6,548 KB
testcase_21 AC 22 ms
6,548 KB
testcase_22 AC 13 ms
6,548 KB
testcase_23 AC 54 ms
6,548 KB
testcase_24 AC 27 ms
6,548 KB
testcase_25 AC 31 ms
6,548 KB
testcase_26 AC 52 ms
6,548 KB
testcase_27 AC 46 ms
6,548 KB
testcase_28 AC 57 ms
6,548 KB
testcase_29 AC 57 ms
6,548 KB
testcase_30 AC 57 ms
6,548 KB
testcase_31 AC 57 ms
6,548 KB
testcase_32 AC 57 ms
6,548 KB
testcase_33 AC 57 ms
6,548 KB
testcase_34 AC 57 ms
6,548 KB
testcase_35 AC 57 ms
6,548 KB
testcase_36 AC 58 ms
6,548 KB
testcase_37 AC 57 ms
6,548 KB
testcase_38 AC 57 ms
6,548 KB
testcase_39 AC 57 ms
6,548 KB
testcase_40 AC 57 ms
6,548 KB
testcase_41 AC 57 ms
6,548 KB
testcase_42 AC 57 ms
6,548 KB
testcase_43 AC 2 ms
6,548 KB
testcase_44 AC 2 ms
6,548 KB
testcase_45 AC 2 ms
6,548 KB
testcase_46 AC 2 ms
6,548 KB
testcase_47 AC 2 ms
6,548 KB
testcase_48 AC 2 ms
6,548 KB
testcase_49 AC 2 ms
6,548 KB
testcase_50 AC 2 ms
6,548 KB
testcase_51 AC 2 ms
6,548 KB
testcase_52 AC 2 ms
6,548 KB
testcase_53 AC 2 ms
6,548 KB
testcase_54 AC 2 ms
6,548 KB
testcase_55 AC 2 ms
6,548 KB
testcase_56 AC 2 ms
6,548 KB
testcase_57 AC 2 ms
6,548 KB
testcase_58 AC 2 ms
6,548 KB
testcase_59 AC 2 ms
6,548 KB
testcase_60 AC 2 ms
6,548 KB
testcase_61 AC 2 ms
6,548 KB
testcase_62 AC 2 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cassert>
#include<atcoder/modint>
using namespace std;
using mint=atcoder::modint998244353;
int M;
int V[1<<17];
long L[1<<17];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>M;
	long n=0;
	for(int i=0;i<M;i++)
	{
		cin>>V[i]>>L[i];
		n+=L[i];
	}
	mint ans=0;
	if(n>=2)
	{//[1,10^{n-1})
		ans+=21;
		ans+=4*(2*(13*mint(10).pow(n)-2200)+9*mint(10).pow(n)*n)/675;
	}
	{//[10^{n-1},N]
		mint N=0;
		int mod3=0;
		for(int i=0;i<M;i++)
		{
			//N -> N*10^{L[i]}+(10^{L[i]}-1)/9*V[i]
			mint t=mint(10).pow(L[i]);
			N=N*t+(t-1)/9*V[i];
			mod3=(mod3+V[i]*L[i])%3;
		}
		int mod5=V[M-1]%5;
		mint p10=mint(10).pow(n-1);
		mint cnt=N-p10+1;
		mint cnt3=0,cnt5=0,cnt15=0;
		{//del [1,p10)
			cnt3-=(p10-1)/3;
			if(n>=2)
			{
				cnt5-=(p10-5)/5;
				cnt15-=(p10-10)/15;
			}
		}
		{//add [1,N]
			cnt3+=(N-mod3)/3;
			cnt5+=(N-mod5)/5;
			int mod15=0;
			while(mod15%3!=mod3||mod15%5!=mod5)mod15++;
			cnt15+=(N-mod15)/15;
		}
		ans+=n*(cnt-cnt3-cnt5+cnt15)+(cnt3+cnt5)*4;
	}
	cout<<ans.val()<<endl;
}
0