結果
問題 | No.372 It's automatic |
ユーザー |
![]() |
提出日時 | 2016-05-13 23:31:01 |
言語 | C++11 (gcc 13.3.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,100 bytes |
コンパイル時間 | 1,327 ms |
コンパイル使用メモリ | 158,828 KB |
実行使用メモリ | 791,132 KB |
最終ジャッジ日時 | 2024-10-05 18:06:29 |
合計ジャッジ時間 | 12,041 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | MLE * 3 |
other | MLE * 2 -- * 21 |
ソースコード
// TLE するだろうなぁ...#include <bits/stdc++.h>using namespace std;#undef _P#define _P(...) (void)printf(__VA_ARGS__)#define FORR(x,arr) for(auto&& x:arr)#define FOR(i,a,b) for (int i = (a); i < (b); i++)#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); i--)#define REP(i,n) for (int i = 0; i < (n); i++)#define RREP(i,n) for (int i = (n)-1; i >= 0; i--)#define ALL(x) (x).begin(), (x).end()#define BIT(n) (1LL<<(n))#define SZ(x) ((int)(x).size())typedef long long ll;// -------------------------------------const long long mod = 1000000007;string S;int M;int N;int dp[10000][20000];int calc(int p) {memset(dp, 0, sizeof(dp));dp[0][0] = 1;REP(i, N-p) REP(j, M) {int d = S[p+i] - '0';(dp[i+1][(j * 10 + d) % M] += dp[i][j]) %= mod;(dp[i+1][j] += dp[i][j]) %= mod;}return dp[N-p][0];}void Main() {cin >> S >> M;N = SZ(S);int ans = calc(0);REP(i, N) {if (S[i] == '0') {ans = (ans - calc(i+1) + mod) % mod;}}_P("%d\n", ans);}int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }