結果

問題 No.2019 Digits Filling for All Substrings
ユーザー okkuukenkenokkuukenken
提出日時 2022-07-22 22:45:44
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 950 bytes
コンパイル時間 1,453 ms
コンパイル使用メモリ 131,296 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-17 11:18:20
合計ジャッジ時間 3,642 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 14 ms
4,380 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 4 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,384 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 34 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 24 ms
4,376 KB
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<random>
using namespace std;
typedef long long ll;
const int mod=998244353;
ll mypow(int x,ll n){
	if(n==0)
		return 1;
	if(n%2==1)
		return mypow(x,n-1)*x%mod;
	ll res=mypow(x,n/2);
	return res*res%mod;
}
ll inv(int x){
	return mypow(x,mod-2);
}
int main(){
	int n;
	string s;
	cin>>n>>s;
	int ans1=0,tmp1=0,tmp2=1;
	for(auto x:s){
		if(x=='?')
			tmp2=tmp2*10ll%mod;
		(tmp1+=tmp2)%=mod;
	}
	for(auto x:s){
		(ans1+=tmp1)%=mod;
		if(x=='?')
			tmp1=(ll)tmp1*inv(10)%mod;
		(tmp1+=mod-1)%=mod;
	}
	int tmp3=(n+1ll)*n/2;
	(ans1+=mod-tmp3%mod)%=mod;
	ans1=(ll)ans1*inv(3)%mod;
	int ans2=0,cnt[3]={1,0,0},sum=0;
	for(auto x:s){
		(sum+=x)%=3;
		(ans2+=cnt[sum])%=mod;
		cnt[sum]++;
	}
	cout<<(ans1+ans2)%mod<<endl;
}
0