結果

問題 No.372 It's automatic
ユーザー yaoshimaxyaoshimax
提出日時 2016-05-14 17:15:56
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 722 bytes
コンパイル時間 656 ms
コンパイル使用メモリ 57,076 KB
実行使用メモリ 814,668 KB
最終ジャッジ日時 2024-04-15 21:30:11
合計ジャッジ時間 3,072 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstring>
using namespace std;
long long dp[10001][20001];
int main(){
   string s;
   int M;
   cin >> s >> M;
   long long ans=0;
   int mod=1000000007;
   int size = s.size();
   memset(dp,0,sizeof(dp));
   for( int i = 0 ; i < size; i++ ){
      if( s[i]=='0' ){
         ans += 1;
      }
      else{
         dp[i+1][(s[i]-'0')%M]+=1;
      }
      for( int m = 0 ; m < M; m++ ){
         int n = (m*10+s[i]-'0')%M;
         dp[i+1][m]+=dp[i][m];
         dp[i+1][m]%=mod;
         dp[i+1][n]+=dp[i][m];
         dp[i+1][n]%=mod;
      }
      //for( int m=0; m<M; m++){
      //   cout << i+1<<","<<m<<": "<<dp[i+1][m]<<endl;
      //}
   }
   cout << (ans+dp[size][0])%mod << endl;

}
0