結果

問題 No.1086 桁和の桁和2
ユーザー kotatsugame
提出日時 2020-06-19 22:50:03
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 611 bytes
コンパイル時間 542 ms
コンパイル使用メモリ 66,728 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-03 15:20:14
合計ジャッジ時間 6,044 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4 WA * 1
other AC * 31
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-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];
	int zc=0;
	for(int i=0;i<N;i++)
	{
		cin>>D[i];
		if(D[i]==0)zc++;
	}
	if(zc>0)
	{
		if(zc==N)cout<<1<<endl;
		else cout<<0<<endl;
		return 0;
	}
	long ans=1;
	long inv9=power(9,mod-2);
	for(int i=0;i<N;i++)
	{
		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