結果

問題 No.372 It's automatic
ユーザー okadukiokaduki
提出日時 2016-05-20 00:47:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,178 ms / 6,000 ms
コード長 1,316 bytes
コンパイル時間 1,826 ms
コンパイル使用メモリ 163,580 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-19 08:29:02
合計ジャッジ時間 16,692 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1,156 ms
5,376 KB
testcase_05 AC 1,167 ms
5,376 KB
testcase_06 AC 1,162 ms
5,376 KB
testcase_07 AC 1,156 ms
5,376 KB
testcase_08 AC 1,169 ms
5,376 KB
testcase_09 AC 1,160 ms
5,376 KB
testcase_10 AC 1,167 ms
5,376 KB
testcase_11 AC 1,159 ms
5,376 KB
testcase_12 AC 1,178 ms
5,376 KB
testcase_13 AC 1,159 ms
5,376 KB
testcase_14 AC 1,173 ms
5,376 KB
testcase_15 AC 1,174 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 55 ms
5,376 KB
testcase_22 AC 56 ms
5,376 KB
testcase_23 AC 56 ms
5,376 KB
testcase_24 AC 55 ms
5,376 KB
testcase_25 AC 55 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_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 FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

LL mod[2][20010];
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  string S; cin >> S;
  int M; cin >> M;
  int N = SZ(S);
  int crt =0, nxt = 1;
  LL zs = 0;
  for(int i=0;i<N;++i){
	REP(m,M) mod[nxt][m] = mod[crt][m];
	int d = S[i] -'0';
	if(!d) ++zs;
	else{
	  mod[nxt][d%M]++;
	  mod[nxt][d%M]%=MOD;
	}
	REP(m,M)
	  mod[nxt][(m*10+d)%M] = (mod[nxt][(m*10+d)%M] + mod[crt][m]) % MOD;

	swap(crt,nxt);
  }
  cout << (mod[crt][0]+zs)%MOD << endl;
  
  return 0;
}
0