Submission #18296628


Source Code Expand

Copy
#include<bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
const int INF = 1e9+1;
using namespace std;
using ll = long long;
using p = pair<int, int>;
using v = vector<int>;

int main(){
  int R;
  string S;
  cin >> R >> S;
  int N = S.size();
  ll Q = 1e9+7;
  vector<vector<vector<ll>>> dp(N+1, vector<vector<ll>>(2, vector<ll>(R, 0)));
  dp[0][0][0] = 1;

  REP(n, N) {
    int D = S[n] - '0';
    cout << "D: " << D << endl;
    REP(f, 2) {
      REP(r, R) {
        for(int d=0; d <= (f ? 9 : D); d++) {
          dp[n+1][f || (d < D)][(r+d)%R] += dp[n][f][r] % Q; 
        }
      }
    }
  }
  REP(i, N+1) {
    cout << "n: " << i << endl;
    REP(j, 2) {
      cout << "f: " << j << endl;
      REP(k, R) {
        cout << dp[i][j][k] << " ";
      }
      cout << endl;
    }
    cout << "-------------------\n";
  }
  cout << (dp[N][0][0] + dp[N][1][0] - 1) << endl;;

  return 0;
}

Submission Info

Submission Time
Task E - 数
User AceK
Language C++ (GCC 9.2.1)
Score 0
Code Size 1015 Byte
Status WA
Exec Time 300 ms
Memory 29916 KB

Judge Result

Set Name All
Score / Max Score 0 / 4
Status
WA × 5
Set Name Test Cases
All 00, 01, 02, 90, 91
Case Name Status Exec Time Memory
00 WA 15 ms 3680 KB
01 WA 221 ms 18680 KB
02 WA 300 ms 29916 KB
90 WA 7 ms 3504 KB
91 WA 4 ms 3508 KB