結果

問題 No.372 It's automatic
ユーザー rickythetarickytheta
提出日時 2016-05-13 23:30:49
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 1,132 bytes
コンパイル時間 1,430 ms
コンパイル使用メモリ 157,952 KB
実行使用メモリ 784,384 KB
最終ジャッジ日時 2024-04-15 17:09:37
合計ジャッジ時間 43,766 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 MLE -
testcase_05 MLE -
testcase_06 MLE -
testcase_07 MLE -
testcase_08 MLE -
testcase_09 MLE -
testcase_10 MLE -
testcase_11 MLE -
testcase_12 MLE -
testcase_13 MLE -
testcase_14 MLE -
testcase_15 MLE -
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 3 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 3 ms
6,940 KB
testcase_20 AC 3 ms
6,940 KB
testcase_21 AC 219 ms
153,572 KB
testcase_22 AC 275 ms
247,924 KB
testcase_23 AC 238 ms
249,400 KB
testcase_24 AC 244 ms
249,848 KB
testcase_25 AC 253 ms
249,820 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:31:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   31 |   scanf("%s",s);
      |   ~~~~~^~~~~~~~
main.cpp:33:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   33 |   scanf("%d",&m);
      |   ~~~~~^~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

char s[12525];
int a[12525];
int n;
int m;

// pos,modM
int dp[10010][20010];

int main(){
  scanf("%s",s);
  n = strlen(s);
  scanf("%d",&m);
  REP(i,n)a[i]=s[i]-'0';
  dp[0][0] = 0;
  int cnt0 = 0;
  REP(pos,n){
    int c = a[pos];
    if(c==0)cnt0++;
    if(c!=0)dp[pos+1][c%m] += 1;
    REP(md,m){
      dp[pos+1][md] += dp[pos][md];
      if(dp[pos+1][md]>=MOD)dp[pos+1][md]-=MOD;
      int nmd = (md*10+c)%m;
      dp[pos+1][nmd] += dp[pos][md];
      if(dp[pos+1][nmd]>=MOD)dp[pos+1][nmd]-=MOD;
    }
  }
  int ans = dp[n][0]+cnt0;
  if(ans>=MOD)ans-=MOD;
  printf("%d\n",ans);
  return 0;
}
0