結果
問題 | No.741 AscNumber(Easy) |
ユーザー |
![]() |
提出日時 | 2020-07-31 03:47:17 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 318 ms / 2,000 ms |
コード長 | 1,469 bytes |
コンパイル時間 | 1,545 ms |
コンパイル使用メモリ | 166,296 KB |
実行使用メモリ | 81,648 KB |
最終ジャッジ日時 | 2024-07-05 07:25:15 |
合計ジャッジ時間 | 7,426 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 55 |
ソースコード
#include <bits/stdc++.h> using namespace std; template<long long mod> class ModInt { public: long long v; ModInt(long long v = 0) : v((v % mod + mod) % mod) {} ModInt operator+(ModInt t) {return ModInt((v + t.v) % mod);} ModInt operator-(ModInt t) {return ModInt((v - t.v + mod) % mod);} ModInt operator*(ModInt t) {return ModInt((v * t.v) % mod);} ModInt operator+=(ModInt t) {return *this = *this + t;} ModInt operator-=(ModInt t) {return *this = *this - t;} ModInt operator*=(ModInt t) {return *this = *this * t;} ModInt operator-() {return ModInt(-v);} ModInt mpow(long long t) { if (t == 0) return ModInt(1); ModInt a = mpow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } ModInt inv() {mpow(mod - 2);} ModInt operator/(ModInt t) {return ModInt(v) * inv();} ModInt operator/=(ModInt t) {return *this = *this / t;} ModInt operator==(ModInt t) {return *this.v == t.v;} ModInt operator!=(ModInt t) {return *this.v != t.v;} friend ostream& operator<<(ostream& os, const ModInt& mi) { os << mi.v; return os; } }; using ll = long long; const ll mod = 1000000007; using mint = ModInt<mod>; mint dp[1000005][10]; int main() { int n; cin >> n; dp[0][0] = 1; for (int i = 1; i <= n; i++) { for (int d = 0; d < 10; d++) { for (int last = 0; last < 10; last++) { if (d >= last) dp[i][d] += dp[i - 1][last]; } } } mint ans = 0; for (int i = 0; i < 10; i++) ans += dp[n][i]; cout << ans << endl; return 0; }