結果

問題 No.1407 Kindness
ユーザー Izayoi_R_sakuraIzayoi_R_sakura
提出日時 2020-11-29 20:06:07
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 1,739 bytes
コンパイル時間 1,408 ms
コンパイル使用メモリ 130,356 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-19 06:17:56
合計ジャッジ時間 3,690 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 63 ms
4,376 KB
testcase_13 AC 14 ms
4,380 KB
testcase_14 AC 18 ms
4,380 KB
testcase_15 AC 57 ms
4,376 KB
testcase_16 AC 35 ms
4,380 KB
testcase_17 AC 23 ms
4,376 KB
testcase_18 AC 22 ms
4,376 KB
testcase_19 AC 51 ms
4,384 KB
testcase_20 AC 43 ms
4,380 KB
testcase_21 AC 4 ms
4,380 KB
testcase_22 AC 6 ms
4,376 KB
testcase_23 AC 40 ms
4,380 KB
testcase_24 AC 70 ms
4,380 KB
testcase_25 AC 22 ms
4,376 KB
testcase_26 AC 31 ms
4,376 KB
testcase_27 AC 5 ms
4,380 KB
testcase_28 AC 56 ms
4,376 KB
testcase_29 AC 3 ms
4,380 KB
testcase_30 AC 63 ms
4,384 KB
testcase_31 AC 14 ms
4,380 KB
testcase_32 AC 52 ms
4,376 KB
testcase_33 AC 18 ms
4,380 KB
testcase_34 AC 39 ms
4,376 KB
testcase_35 AC 15 ms
4,376 KB
testcase_36 AC 3 ms
4,380 KB
testcase_37 AC 71 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <math.h>
#include <random>
#include <chrono>
using namespace std ;
using ll = long long ;
using ld = long double ;
template<class T> using V = vector<T> ;
template<class T> using VV = V<V<T>> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
ll mod = 1e9+7 ;
long double pie = acos(-1) ;
ll INF = 1000000000000 ;

void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
void fix_cout(){cout << fixed << setprecision(20) ;}
template<class T> void chmax(T &a,T &b){if(a<b) a = b ;}
template<class T> void chmin(T &a,T &b){if(a>b) a = b ;}

ll modpow(ll a,ll b){
	ll res = 1 ;
	while(b){
		if(b&1) res = res*a%mod ;
		a = a*a%mod ;
		b >>= 1 ;
	}
	return res ;
}

ll f(int n){
	string s = to_string(n) ;
	ll res = 1 ;
	for(int i=0;i<s.size();i++) res = res*(s[i]-'0')%mod ;
	return res ;
}

int main(){
	string n ; cin >> n ;
	int d = n.size() ;
	V<int> sum = {0,1,3,6,10,15,21,28,36,45} ;
	ll ans = sum[n[0]-'0'-1]*modpow(45,d-1)%mod ;
	ll mul = n[0]-'0' ;
	for(int i=1;i<d;i++){
		ans += modpow(45,d-i) ;
		ans += sum[max(0,n[i]-'0'-1)]*modpow(45,d-i-1)%mod*mul%mod ;
		ans %= mod ;
		mul = mul*(n[i]-'0')%mod ;
	}
	ans += mul ;
	cout << ans%mod << endl ;
	// ll sub = 0 ;
	// int nn = stoi(n) ;
	// for(int i=1;i<=nn;i++) sub = (sub+f(i))%mod ;
	// cout << sub << endl ;
}
0