結果

問題 No.1407 Kindness
ユーザー morimariomorimario
提出日時 2021-02-26 22:14:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 4,287 bytes
コンパイル時間 3,781 ms
コンパイル使用メモリ 260,188 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-10 12:59:46
合計ジャッジ時間 4,864 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 8 ms
6,940 KB
testcase_13 AC 3 ms
6,944 KB
testcase_14 AC 3 ms
6,940 KB
testcase_15 AC 8 ms
6,940 KB
testcase_16 AC 6 ms
6,940 KB
testcase_17 AC 4 ms
6,940 KB
testcase_18 AC 4 ms
6,940 KB
testcase_19 AC 8 ms
6,944 KB
testcase_20 AC 6 ms
6,940 KB
testcase_21 AC 1 ms
6,944 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 6 ms
6,944 KB
testcase_24 AC 9 ms
6,940 KB
testcase_25 AC 4 ms
6,944 KB
testcase_26 AC 6 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 7 ms
6,940 KB
testcase_29 AC 2 ms
6,944 KB
testcase_30 AC 9 ms
6,944 KB
testcase_31 AC 3 ms
6,940 KB
testcase_32 AC 7 ms
6,940 KB
testcase_33 AC 3 ms
6,944 KB
testcase_34 AC 6 ms
6,944 KB
testcase_35 AC 3 ms
6,944 KB
testcase_36 AC 2 ms
6,940 KB
testcase_37 AC 8 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long; using pil = pair<int, ll>; using pli = pair<ll, int>;
using pii = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using pll = pair<ll, ll>; using vl = vector<ll>; using vvl = vector<vl>; using vvvl = vector<vvl>;
using pbb = pair<bool, bool>; using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using pcc = pair<char, char>; using vc = vector<char>; using vvc = vector<vc>; using vvvc = vector<vvc>;
using pss = pair<string, string>; using vs = vector<string>; using vvs = vector<vs>; using vvvs = vector<vvs>;
using pdd = pair<double, double>; using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
template <typename T> using pq = priority_queue<T, vector<T>>; template <typename T> using pql = priority_queue<T, vector<T>, greater<T>>;
#define rep0(times) for(int counter = 0; counter < (int)(times); ++counter)
#define rep(counter, goal) for (int counter = 0; counter < (int)(goal); ++counter)
#define rep2(counter, start, goal) for (int counter = (int)(start); counter < (int)(goal); ++counter)
#define rep3(counter, start, goal) for (int counter = (int)(start); counter > (int)(goal); --counter)
#define all(container) begin(container), end(container)
template <typename T> bool chmax(T &x, const T &y) { if (x < y) { x = y; return true; } return false; }
template <typename T> bool chmin(T &x, const T &y) { if (x > y) { x = y; return true; } return false; }
void Yn(bool flag) { cout << (flag ? "Yes" : "No") << "\n"; }
void yn(bool flag) { cout << (flag ? "yes" : "no") << "\n"; }
void YN(bool flag) { cout << (flag ? "YES" : "NO") << "\n"; }
void set_prec(const int &digits) { cout << fixed << setprecision(digits); cerr << fixed << setprecision(digits); }
template <typename T> T INF() { return numeric_limits<T>::max(); }
#include <atcoder/all>
using namespace atcoder;
using mint = atcoder::modint1000000007;
// using mint = atcoder::modint998244353;
// using mint = atcoder::modint;
using pmm = pair<mint, mint>; using vm = vector<mint>; using vvm = vector<vm>; using vvvm = vector<vvm>;
void pr(const mint &obj) { cerr << obj.val(); }
template <typename T> void pr(const T &obj) { cerr << obj; }
template <typename T, typename ...Ts> void pr(const T &first, const Ts &...rest) { pr(first); pr(", "); pr(rest...); }
template <typename S, typename T> void pr(const pair<S, T> &pair) { pr("("); pr(pair.first); pr(", "); pr(pair.second); pr(")"); }
template <typename T> void pr(const vector<T> &vec) { pr("{"); for (T obj : vec) { pr(obj); pr(", "); } pr("}"); }
template <typename T> void pr(const vector<vector<T>> &vv) { pr("\n"); rep(index, vv.size()) { pr("["); pr(index); pr("]: "); pr(vv[index]); pr("\n"); } }
template <typename T> void pr(const set<T> &vec) { pr("{"); for (T obj : vec) { pr(obj); pr(", "); } pr("}"); }
template <typename S, typename T> void pr(const map<S, T> &map) { pr("{"); for (pair<S, T> pair : map) { pr("("); pr(pair.first); pr(": "); pr(pair.second); pr("), "); } pr("}"); }
#define db(obj) cerr << #obj << ": "; pr(obj); cerr << " "
#define dl(obj) db(obj); cerr << "\n"
#define dm(...) cerr << "(" << #__VA_ARGS__ << "): ("; pr(__VA_ARGS__); cerr << ") "
#define dml(...) dm(__VA_ARGS__); cerr << "\n"
const ll MOD = 1000000007;
// const ll MOD = 998244353;

// 桁DP
// dp[r]: non-zero かつ smallerで、Nの上位桁の末尾がrであるようなものについての桁の積の和
// just: justな数についての桁の積

int main() {
	string N; cin >> N;
	int d = N[0] - '0'; // 先頭桁をまず見る
	vm dp(10);
	rep(r, d) dp[r] = r; // smaller
	mint just(d); // just
	// dl(dp); dl(just); // *
	if (N.length() > 1) {
		rep2(i, 1, N.size()) {
			int d = N[i] - '0';
			vm temp(10, 0);
			// smaller -> smaller
			rep(r, 10) temp[r] += dp[r] * 45;
			// zero -> smaller
			rep2(r, 1, 10) temp[r] += r;
			// just -> smaller
			rep2(r, 1, d) temp[r] += just * r;
			// just -> just
			just *= d;
			// zero -> just はない
			dp = temp;
			// db(d); dl(dp); dl(just);
		}
	}
	// dl(dp);
	dp[N[N.length() - 1] - '0'] += just;
	// dl(dp);
	mint ans = 0;
	rep(r, 10) ans += dp[r];
	cout << ans.val() << endl;
}
0