結果
問題 |
No.741 AscNumber(Easy)
|
ユーザー |
|
提出日時 | 2025-01-07 12:09:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 710 ms / 2,000 ms |
コード長 | 819 bytes |
コンパイル時間 | 1,621 ms |
コンパイル使用メモリ | 168,848 KB |
実行使用メモリ | 278,648 KB |
最終ジャッジ日時 | 2025-01-07 12:09:41 |
合計ジャッジ時間 | 12,227 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 55 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; const int INF = 1073741823; const ll INFl = 1LL << 60; #define rep(i, n) for (int i = 0; i < (int)(n); i++) const ll MOD = 1000000007; using vec = vector<ll>; using mat = vector<vec>; using matx = vector<mat>; ll f(string x) { int n = x.size(); matx dp(n+1, mat(2, vec(10, 0))); dp[0][0][0] = 1; rep(i, n)rep(j, 2)rep(k, 10) { int lim = j ? 9:x[i]-'0'; rep(d, lim + 1) { if(d < k) continue; dp[i+1][j||d<x[i]-'0'][d] += dp[i][j][k]; dp[i+1][j||d<x[i]-'0'][d] %= MOD; } } ll res = 0; rep(k, 10) { res += dp[n][0][k] + dp[n][1][k]; res %= MOD; } return res; } int main() { int N; cin >> N; string x = "1"; rep(i, N) x+='0'; cout << f(x) << endl; }