結果
問題 |
No.1417 100の倍数かつ正整数(2)
|
ユーザー |
|
提出日時 | 2021-03-09 19:48:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 22 ms / 3,000 ms |
コード長 | 1,557 bytes |
コンパイル時間 | 4,062 ms |
コンパイル使用メモリ | 237,792 KB |
実行使用メモリ | 10,288 KB |
最終ジャッジ日時 | 2024-10-11 12:32:59 |
合計ジャッジ時間 | 5,798 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 |
ソースコード
#include <bits/stdc++.h> #define pt(sth) cout << sth << "\n" #define itr(x,c) for(auto x=c.begin();x!=c.end();x++) #define all(a) (a.begin()),(a.end()) using namespace std; #include <atcoder/all> using namespace atcoder; typedef long long ll; typedef pair<ll, ll> pll; template<class T>bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;} template<class T>bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;} static const ll INF=1e18; static const ll MAX=101010; static const ll MOD=1e9+7; //static const ll MOD=998244353; //for(i=0;i<N;i++) cin>>a[i]; typedef vector<ll> v1D; typedef vector<v1D> v2D; typedef vector<v2D> v3D; typedef vector<v3D> v4D; v4D dp(11111,v3D(3,v2D(3,v1D(2,0)))); int main(void) { ll i,j,k,l; string s;cin>>s; // dp[i+1][2][5][eq] dp[0][0][0][1]=1; for(i=0;i<s.size();i++) dp[i+1][0][0][0]=1; for(i=0;i<s.size();i++){ for(j=0;j<3;j++){ for(k=0;k<3;k++){ for(l=0;l<2;l++){ ll lim=(l==1?s[i]-'0':9); for(ll d=1;d<=lim;d++){ if(d%4==0){ (dp[i+1][min(j+2,2LL)][k][l and d==lim]+=dp[i][j][k][l])%=MOD; }else if(d%2==0){ (dp[i+1][min(j+1,2LL)][k][l and d==lim]+=dp[i][j][k][l])%=MOD; }else if(d%5==0){ (dp[i+1][j][min(k+1,2LL)][l and d==lim]+=dp[i][j][k][l])%=MOD; }else{ (dp[i+1][j][k][l and d==lim]+=dp[i][j][k][l])%=MOD; } } } } } } pt((dp[s.size()][2][2][0]+dp[s.size()][2][2][1])%MOD); }