結果

問題 No.1407 Kindness
ユーザー kotatsugame
提出日時 2021-02-28 01:36:15
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 376 bytes
コンパイル時間 549 ms
コンパイル使用メモリ 66,588 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-02 18:06:26
合計ジャッジ時間 1,841 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 36
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
const long mod=1e9+7;
string N;
long dp[1<<17][2];
main()
{
	cin>>N;
	for(int i=0;i<N.size();i++)
	{
		for(int j=0;j<2;j++)
		{
			int lim=j?9:N[i]-'0';
			for(int k=1;k<=lim;k++)
			{
				(dp[i+1][j||k<lim]+=dp[i][j]*k)%=mod;
				if(i?j:!j)(dp[i+1][j||k<lim]+=k)%=mod;
			}
		}
	}
	cout<<(dp[N.size()][0]+dp[N.size()][1])%mod<<endl;
}
0