結果

問題 No.1407 Kindness
ユーザー 沙耶花沙耶花
提出日時 2021-02-26 21:29:43
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 872 bytes
コンパイル時間 4,181 ms
コンパイル使用メモリ 259,792 KB
実行使用メモリ 42,508 KB
最終ジャッジ日時 2024-04-10 12:02:35
合計ジャッジ時間 6,242 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
28,340 KB
testcase_01 AC 28 ms
28,280 KB
testcase_02 AC 26 ms
28,192 KB
testcase_03 AC 26 ms
28,272 KB
testcase_04 AC 27 ms
28,252 KB
testcase_05 AC 27 ms
28,368 KB
testcase_06 AC 26 ms
28,340 KB
testcase_07 AC 28 ms
28,252 KB
testcase_08 AC 27 ms
28,160 KB
testcase_09 AC 27 ms
28,328 KB
testcase_10 AC 28 ms
28,220 KB
testcase_11 AC 27 ms
28,212 KB
testcase_12 AC 61 ms
40,976 KB
testcase_13 AC 33 ms
30,960 KB
testcase_14 AC 36 ms
32,040 KB
testcase_15 AC 57 ms
39,756 KB
testcase_16 AC 45 ms
35,396 KB
testcase_17 AC 39 ms
33,184 KB
testcase_18 AC 38 ms
32,748 KB
testcase_19 AC 55 ms
38,732 KB
testcase_20 AC 48 ms
37,032 KB
testcase_21 AC 31 ms
28,852 KB
testcase_22 AC 31 ms
29,336 KB
testcase_23 AC 48 ms
36,560 KB
testcase_24 AC 65 ms
42,212 KB
testcase_25 AC 39 ms
32,796 KB
testcase_26 AC 43 ms
34,852 KB
testcase_27 AC 31 ms
29,248 KB
testcase_28 AC 59 ms
39,712 KB
testcase_29 AC 30 ms
28,760 KB
testcase_30 AC 61 ms
40,768 KB
testcase_31 AC 37 ms
31,168 KB
testcase_32 AC 57 ms
38,932 KB
testcase_33 AC 38 ms
32,060 KB
testcase_34 AC 45 ms
36,352 KB
testcase_35 AC 35 ms
31,348 KB
testcase_36 AC 28 ms
28,604 KB
testcase_37 AC 60 ms
42,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint1000000007;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001

string N;

mint get(int ind,int f){
	if(ind==N.size())return 1;
	static vector dp(200000,vector<mint>(2,0));
	static vector visited(200000,vector<bool>(2,false));
	if(visited[ind][f])return dp[ind][f];
	
	visited[ind][f] = true;
	mint ret = 0;
	
	rep(i,10){
		int t =  N[ind] - '0';
		if(i<t){
			ret += get(ind+1,1) * i;
		}
		else if(i==t){
			ret += get(ind+1,f) * i;
		}
		else{
			if(f==0)continue;
			ret += get(ind+1,f) * i;
		}
	}
	dp[ind][f] = ret;
	return ret;
	
}

int main(){
	
	cin>>N;
	//reverse(N.begin(),N.end());
	
	mint ans = get(0,0);
	
	rep(i,N.size()){
	
		ans += mint(45).pow(i);
	}
	ans--;
	
	cout<<ans.val()<<endl;
	
    return 0;
}
0