Submission #97553
Source Code Expand
Copy
#include <vector> #include <list> #include <map> #include <set> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <queue> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <cctype> #include <string> #include <cstring> #include <ctime> #include <fstream> #include <stdio.h> #include <complex> using namespace std; //conversion //------------------------------------------ inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;} template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();} //typedef //------------------------------------------ typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef pair<int, PII> TIII; typedef long long LL; typedef vector<LL> VLL; //container util //------------------------------------------ #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define MP make_pair #define SZ(a) int((a).size()) #define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i) #define EXIST(s,e) ((s).find(e)!=(s).end()) #define SORT(c) sort((c).begin(),(c).end()) #define MT(a,b,c) MP(a, MP(b, c)) //repetition //------------------------------------------ #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define MOD 1000000007 LL dp[2][2][100]; int main(){ int d; cin>>d; string str; cin>>str; int n=str.length(); dp[0][1][0]=1; REP(i,n){ memset(dp[(i+1)%2], 0, sizeof(dp[(i+1)%2])); REP(j,d){ REP(k,10){ dp[(i+1)%2][0][j]+=dp[i%2][0][(j-k+d*10)%d]; dp[(i+1)%2][0][j]%=MOD } } REP(j,d){ REP(k,str[i]-'0'){ dp[(i+1)%2][0][j]+=dp[i%2][1][(j-k+d)%d]; dp[(i+1)%2][0][j]%=MOD; } } REP(j,d){ dp[(i+1)%2][1][j]+=dp[i%2][1][(j-str[i]+'0'+d)%d]; dp[(i+1)%2][1][j]%=MOD; } } cout << dp[n%2][0][0]+dp[n%2][1][0] -1<< endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - 数 |
User | UminchuR |
Language | C++ (G++ 4.6.4) |
Score | 0 |
Code Size | 2160 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:79:4: error: expected ‘;’ before ‘}’ token