結果

問題 No.1086 桁和の桁和2
ユーザー kotatsugamekotatsugame
提出日時 2020-06-19 22:52:49
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 257 ms / 3,000 ms
コード長 580 bytes
コンパイル時間 592 ms
コンパイル使用メモリ 65,256 KB
実行使用メモリ 5,904 KB
最終ジャッジ日時 2023-09-29 23:50:57
合計ジャッジ時間 7,085 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 242 ms
5,676 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 150 ms
4,872 KB
testcase_11 AC 41 ms
4,380 KB
testcase_12 AC 9 ms
4,376 KB
testcase_13 AC 191 ms
5,256 KB
testcase_14 AC 120 ms
4,628 KB
testcase_15 AC 31 ms
4,380 KB
testcase_16 AC 178 ms
5,128 KB
testcase_17 AC 16 ms
4,384 KB
testcase_18 AC 247 ms
5,636 KB
testcase_19 AC 204 ms
5,276 KB
testcase_20 AC 26 ms
4,384 KB
testcase_21 AC 175 ms
5,224 KB
testcase_22 AC 245 ms
5,540 KB
testcase_23 AC 151 ms
4,696 KB
testcase_24 AC 105 ms
4,376 KB
testcase_25 AC 206 ms
5,280 KB
testcase_26 AC 172 ms
5,040 KB
testcase_27 AC 122 ms
4,544 KB
testcase_28 AC 101 ms
4,376 KB
testcase_29 AC 113 ms
4,464 KB
testcase_30 AC 257 ms
5,680 KB
testcase_31 AC 254 ms
5,696 KB
testcase_32 AC 254 ms
5,628 KB
testcase_33 AC 254 ms
5,700 KB
testcase_34 AC 256 ms
5,904 KB
testcase_35 AC 243 ms
5,856 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
const long mod=1e9+7;
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
int N;
long L[1<<17],R[1<<17],D[1<<17];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)cin>>L[i];
	for(int i=0;i<N;i++)cin>>R[i];
	for(int i=0;i<N;i++)cin>>D[i];
	long ans=1;
	long inv9=power(9,mod-2);
	bool nz=false;
	for(int i=0;i<N;i++)
	{
		if(D[i]==0)
		{
			if(nz)ans=0;
		}
		else
		{
			nz=true;
			long now=(power(10,R[i])-power(10,L[i])+mod)%mod*inv9%mod;
			if(i>0&&D[i-1]==D[i])now=(now+1)%mod;
			ans=ans*now%mod;
		}
	}
	cout<<ans<<endl;
}
0