結果
問題 | No.260 世界のなんとか3 |
ユーザー | Hank |
提出日時 | 2017-08-29 23:57:36 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,604 bytes |
コンパイル時間 | 686 ms |
コンパイル使用メモリ | 79,684 KB |
実行使用メモリ | 11,168 KB |
最終ジャッジ日時 | 2023-08-06 06:51:28 |
合計ジャッジ時間 | 5,487 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | WA | - |
testcase_04 | AC | 257 ms
10,952 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 69 ms
6,588 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 112 ms
8,644 KB |
testcase_13 | WA | - |
testcase_14 | AC | 169 ms
9,836 KB |
testcase_15 | AC | 46 ms
4,752 KB |
testcase_16 | AC | 147 ms
8,584 KB |
testcase_17 | WA | - |
testcase_18 | AC | 112 ms
6,764 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 130 ms
9,336 KB |
testcase_25 | AC | 168 ms
10,956 KB |
testcase_26 | AC | 93 ms
11,168 KB |
testcase_27 | AC | 1 ms
4,376 KB |
testcase_28 | AC | 255 ms
10,916 KB |
testcase_29 | AC | 331 ms
10,920 KB |
ソースコード
#include <iostream> #include <iomanip> #include <vector> #include <algorithm> #include <cstring> #include <map> #include <queue> #include <cmath> #define MOD 1000000007 #define ll long long #define ld long double #define FOR(i,a,b) for(ll i=(a);i<(b);i++) #define rep(i,n) FOR(i,0,n) using namespace std; ll withMod2DP(string s, ll _witha, ll _moda,ll _modb){ ll n = s.size(); ll dp[n+1][2][2][_moda][_modb]; // keta,less,forbid, mod _moda, mod _modb rep(i,n+1)rep(j,2)rep(k,2)rep(l,_moda)rep(m,_modb) dp[i][j][k][l][m] = 0; dp[0][0][0][0][0] = 1; rep(keta,n)rep(less,2)rep(ng,2)rep(l,_moda)rep(m,_modb){ int lim = less? 9 : s[keta]-'0'; rep(d,lim+1) (dp[keta+1][less||d<lim][ng||d==_witha][(l+d)%_moda][(m*10+d)%8] += dp[keta][less][ng][l][m])%=MOD; } ll result = 0; rep(less,2)rep(ng,2)rep(l,_moda)rep(m,_modb){ //modaで割ってあまりが0, modbで割って、あまりが0じゃない if( (ng || l==0) && m!=0)(result += dp[n][less][ng][l][m])%=MOD; } return result; } ll check(string S){ // is aho: mod 3 = 0 or with 3 return 1 ll n = S.size(); ll sum = 0; rep(i,n){ if(S[i]== '3') return 1; sum += (S[i]-'3'); } if((sum%3)==0) return 1; // seisyun sinai :mod 8 != 0 return 1 return 0; } int main(){ cin.tie(0); ios::sync_with_stdio(false); string A,B; cin >> A >> B; ll n = A.size(); rep(i,n){ if(A[n-i-1]=='0')A[n-i-1]='9'; else{ A[n-i-1]-=1; break; } } ll na = withMod2DP(A, 3, 3, 8); ll nb = withMod2DP(B, 3, 3, 8); cout << nb - na << endl; }