結果
問題 | No.260 世界のなんとか3 |
ユーザー | kotatsugame |
提出日時 | 2020-10-09 19:10:14 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 108 ms / 2,000 ms |
コード長 | 2,841 bytes |
コンパイル時間 | 504 ms |
コンパイル使用メモリ | 66,788 KB |
実行使用メモリ | 7,324 KB |
最終ジャッジ日時 | 2023-09-27 13:51:34 |
合計ジャッジ時間 | 3,300 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 86 ms
7,132 KB |
testcase_04 | AC | 86 ms
7,324 KB |
testcase_05 | AC | 18 ms
4,832 KB |
testcase_06 | AC | 13 ms
4,376 KB |
testcase_07 | AC | 60 ms
6,588 KB |
testcase_08 | AC | 44 ms
6,676 KB |
testcase_09 | AC | 23 ms
5,032 KB |
testcase_10 | AC | 65 ms
6,268 KB |
testcase_11 | AC | 61 ms
6,844 KB |
testcase_12 | AC | 38 ms
6,012 KB |
testcase_13 | AC | 12 ms
4,376 KB |
testcase_14 | AC | 58 ms
6,620 KB |
testcase_15 | AC | 16 ms
4,380 KB |
testcase_16 | AC | 50 ms
6,084 KB |
testcase_17 | AC | 40 ms
5,464 KB |
testcase_18 | AC | 38 ms
5,044 KB |
testcase_19 | AC | 48 ms
6,636 KB |
testcase_20 | AC | 35 ms
5,440 KB |
testcase_21 | AC | 31 ms
5,752 KB |
testcase_22 | AC | 58 ms
6,056 KB |
testcase_23 | AC | 6 ms
4,376 KB |
testcase_24 | AC | 44 ms
6,360 KB |
testcase_25 | AC | 58 ms
7,156 KB |
testcase_26 | AC | 34 ms
7,196 KB |
testcase_27 | AC | 2 ms
4,376 KB |
testcase_28 | AC | 85 ms
7,192 KB |
testcase_29 | AC | 108 ms
7,184 KB |
コンパイルメッセージ
a.cpp:25:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
ソースコード
#line 1 "a.cpp" #include<iostream> using namespace std; #line 3 "/home/kotatsugame/library/math/modint.cpp" #include<utility> template<int m> struct modint{ unsigned int x; constexpr modint()noexcept:x(){} constexpr modint(long long _x)noexcept:x((_x%=m)<0?_x+m:_x){} constexpr unsigned int val()const noexcept{return x;} constexpr modint&operator++()noexcept{if(++x==m)x=0;return*this;} constexpr modint&operator--()noexcept{if(x==0)x=m;--x;return*this;} constexpr modint operator++(int)noexcept{modint res=*this;++*this;return res;} constexpr modint operator--(int)noexcept{modint res=*this;--*this;return res;} constexpr modint&operator+=(const modint&a)noexcept{x+=a.x;if(x>=m)x-=m;return*this;} constexpr modint&operator-=(const modint&a)noexcept{if(x<a.x)x+=m;x-=a.x;return*this;} constexpr modint&operator*=(const modint&a)noexcept{x=(unsigned long long)x*a.x%m;return*this;} constexpr modint&operator/=(const modint&a)noexcept{return*this*=a.inv();} constexpr modint operator+()const noexcept{return*this;} constexpr modint operator-()const noexcept{return modint()-*this;} constexpr modint pow(long long n)const noexcept { if(n<0)return pow(-n).inv(); modint x=*this,r=1; for(;n;x*=x,n>>=1)if(n&1)r*=x; return r; } constexpr modint inv()const noexcept { int s=x,t=m,x=1,u=0; while(t) { int k=s/t; s-=k*t; swap(s,t); x-=k*u; swap(x,u); } return modint(x); } friend constexpr modint operator+(const modint&a,const modint&b){return modint(a)+=b;} friend constexpr modint operator-(const modint&a,const modint&b){return modint(a)-=b;} friend constexpr modint operator*(const modint&a,const modint&b){return modint(a)*=b;} friend constexpr modint operator/(const modint&a,const modint&b){return modint(a)/=b;} friend constexpr modint operator==(const modint&a,const modint&b){return a.x==b.x;} friend constexpr modint operator!=(const modint&a,const modint&b){return a.x!=b.x;} friend ostream&operator<<(ostream&os,const modint&a){return os<<a.x;} friend istream&operator>>(istream&is,modint&a){long long v;is>>v;a=modint(v);return is;} }; #line 4 "a.cpp" using mint=modint<(int)1e9+7>; mint dp[10101][2][2][24]; mint f(string A) { for(int i=0;i<=A.size();i++)for(int j=0;j<2;j++)for(int k=0;k<2;k++)for(int l=0;l<24;l++)dp[i][j][k][l]=0; dp[0][0][0][0]=1; for(int i=0;i<A.size();i++)for(int j=0;j<2;j++) { int lim=j?9:A[i]-'0'; for(int K=0;K<2;K++)for(int k=0;k<24;k++)for(int l=0;l<=lim;l++) { dp[i+1][j||l<lim][K||l==3][(k*10+l)%24]+=dp[i][j][K][k]; } } mint ans=0; for(int i=0;i<2;i++)for(int j=0;j<2;j++)for(int k=1;k<24;k++) { if(k%8!=0&&(j||k%3==0))ans+=dp[A.size()][i][j][k]; } return ans; } main() { string A,B; cin>>A>>B; for(int i=A.size();i--;) { if(A[i]=='0')A[i]='9'; else { A[i]--; break; } } cout<<f(B)-f(A)<<endl; }