結果

問題 No.372 It's automatic
ユーザー rickythetarickytheta
提出日時 2016-05-13 23:29:44
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 1,131 bytes
コンパイル時間 1,257 ms
コンパイル使用メモリ 158,592 KB
実行使用メモリ 814,048 KB
最終ジャッジ日時 2024-04-15 17:07:42
合計ジャッジ時間 4,838 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 MLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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
ll 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