Hướng dẫn giải của Bedao Grand Contest 04 - REFI
Chỉ dùng lời giải này khi không có ý tưởng, và đừng copy-paste code từ lời giải này. Hãy tôn trọng người ra đề và người viết lời giải.
Nộp một lời giải chính thức trước khi tự giải là một hành động có thể bị ban.
Nộp một lời giải chính thức trước khi tự giải là một hành động có thể bị ban.
Code mẫu
#include <bits/stdc++.h> using namespace std; #define tag "REFI" #define maxn 100007 #define oo 1000000007 #define meset(a,x) memset(a,x,sizeof(a)) #define checkfile(FiLeNaMe) { if(fopen(FiLeNaMe".inp","r")) freopen(FiLeNaMe".inp","r",stdin),freopen(FiLeNaMe".out","w",stdout); } ///>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #define base 17 #define MOD 998244353 int n; int main() { checkfile(tag); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; cin>>s; n=s.size(); int f[base],g[base]; meset(f,0); f[0]=1; for(const char &c: s) { meset(g,0); for(int i=0;i<10;i++) { if(c!='?' && c!='0'+i) continue; for(int k=0;k<base;k++) (g[(k*10+i)%base]+=f[k])%=MOD; } swap(f,g); } cout<<f[5]; return 0; }
Bình luận