結果
| 問題 |
No.1417 100の倍数かつ正整数(2)
|
| コンテスト | |
| ユーザー |
SSRS
|
| 提出日時 | 2021-03-05 21:31:16 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 463 ms / 3,000 ms |
| コード長 | 1,107 bytes |
| コンパイル時間 | 1,779 ms |
| コンパイル使用メモリ | 176,920 KB |
| 実行使用メモリ | 152,192 KB |
| 最終ジャッジ日時 | 2024-10-07 00:38:09 |
| 合計ジャッジ時間 | 5,534 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 36 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int main(){
string N;
cin >> N;
int M = N.size();
vector<vector<vector<vector<long long>>>> dp(M + 1, vector<vector<vector<long long>>>(100, vector<vector<long long>>(2, vector<long long>(2, 0))));
dp[0][1][0][0] = 1;
for (int i = 0; i < M; i++){
for (int j = 0; j < 100; j++){
for (int k = 0; k < 2; k++){
for (int l = 0; l < 2; l++){
for (int d = 0; d <= 9; d++){
if (k == 0 && d > N[i] - '0'){
continue;
}
if (l == 1 && d == 0){
continue;
}
int j2 = j;
if (d > 0){
j2 = j * d % 100;
}
int k2 = k;
if (d < N[i] - '0'){
k2 = 1;
}
int l2 = l;
if (d != 0){
l2 = 1;
}
dp[i + 1][j2][k2][l2] += dp[i][j][k][l];
dp[i + 1][j2][k2][l2] %= MOD;
}
}
}
}
}
cout << (dp[M][0][0][1] + dp[M][0][1][1]) % MOD << endl;
}
SSRS