結果
| 問題 | No.260 世界のなんとか3 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-05-05 00:39:51 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 96 ms / 2,000 ms |
| コード長 | 959 bytes |
| 記録 | |
| コンパイル時間 | 496 ms |
| コンパイル使用メモリ | 81,260 KB |
| 実行使用メモリ | 7,976 KB |
| 最終ジャッジ日時 | 2026-05-05 00:39:58 |
| 合計ジャッジ時間 | 2,946 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#include<iostream>
#include<cassert>
#include<atcoder/modint>
using namespace std;
using mint=atcoder::modint1000000007;
mint dp[2][2][2][24];
mint f(string A)
{
int now=0;
for(int j=0;j<2;j++)for(int k=0;k<2;k++)for(int l=0;l<24;l++)dp[now][j][k][l]=0;
dp[now][0][0][0]=1;
for(char c:A)
{
int nxt=1-now;
for(int j=0;j<2;j++)for(int k=0;k<2;k++)for(int l=0;l<24;l++)dp[nxt][j][k][l]=0;
for(int j=0;j<2;j++)
{
int lim=j?9:c-'0';
for(int K=0;K<2;K++)for(int k=0;k<24;k++)for(int l=0;l<=lim;l++)
{
dp[nxt][j||l<lim][K||l==3][(k*10+l)%24]+=dp[now][j][K][k];
}
}
now=nxt;
}
mint ans=0;
for(int j=0;j<2;j++)for(int k=0;k<2;k++)for(int l=0;l<24;l++)
{
if(l%8!=0&&(k||l%3==0))ans+=dp[now][j][k][l];
}
return ans;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
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)).val()<<endl;
}