結果

問題 No.260 世界のなんとか3
ユーザー 沙耶花沙耶花
提出日時 2022-03-25 17:09:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 960 bytes
コンパイル時間 4,121 ms
コンパイル使用メモリ 260,808 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 02:58:37
合計ジャッジ時間 6,269 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 84 ms
5,376 KB
testcase_04 AC 86 ms
5,376 KB
testcase_05 AC 17 ms
5,376 KB
testcase_06 AC 12 ms
5,376 KB
testcase_07 AC 58 ms
5,376 KB
testcase_08 AC 40 ms
5,376 KB
testcase_09 AC 23 ms
5,376 KB
testcase_10 AC 65 ms
5,376 KB
testcase_11 AC 60 ms
5,376 KB
testcase_12 AC 37 ms
5,376 KB
testcase_13 AC 11 ms
5,376 KB
testcase_14 AC 54 ms
5,376 KB
testcase_15 AC 15 ms
5,376 KB
testcase_16 AC 47 ms
5,376 KB
testcase_17 AC 38 ms
5,376 KB
testcase_18 AC 37 ms
5,376 KB
testcase_19 AC 48 ms
5,376 KB
testcase_20 AC 34 ms
5,376 KB
testcase_21 AC 31 ms
5,376 KB
testcase_22 AC 55 ms
5,376 KB
testcase_23 AC 7 ms
5,376 KB
testcase_24 AC 45 ms
5,376 KB
testcase_25 AC 48 ms
5,376 KB
testcase_26 AC 37 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 74 ms
5,376 KB
testcase_29 AC 94 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

mint get(string s,bool f){
	vector dp(24,vector(2,vector<mint>(2,0)));
	dp[0][0][0] = 1;
	rep(i,s.size()){
		vector ndp(24,vector(2,vector<mint>(2,0)));
		int n = s[i] - '0';
		rep(j,24){
			rep(k,2){
				rep(l,2){
					
					rep(m,10){
						int jj = j*10 + m;
						jj %= 24;
						int kk = k;
						int ll = l;
						if(kk==0 && m>n)break;
						if(m<n)kk = 1;
						if(m==3)ll = 1;
						ndp[jj][kk][ll] += dp[j][k][l];
					}
				}
			}
		}
		swap(dp,ndp);
	}
	mint ret = 0;
	rep(i,24){
		rep(j,2){
			rep(k,2){
				if(!f&&j==0)continue;
				if((k==1 || i%3==0) && i%8!=0)ret += dp[i][j][k];
			}
		}
	}
	return ret;
}
		

int main(){
	
	string A,B;
	cin>>A>>B;
	mint ans = get(B,true);
	ans -= get(A,false);
	cout<<ans.val()<<endl;
	
	return 0;
}
0