結果
| 問題 |
No.260 世界のなんとか3
|
| コンテスト | |
| ユーザー |
C7C7LL
|
| 提出日時 | 2018-07-26 13:49:17 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 766 bytes |
| コンパイル時間 | 1,358 ms |
| コンパイル使用メモリ | 159,820 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-01 03:17:25 |
| 合計ジャッジ時間 | 2,612 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 3 WA * 24 |
コンパイルメッセージ
main.cpp:23:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
23 | main(){
| ^~~~
ソースコード
#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int dp[22][2][2][3][8],n,m,sum,p,A,k,M=1e9+7,f;
string s,t;
int dfs(int idx,bool tight=1,bool ok=0,int mod=0,int mod2=0){
if(idx==s.size())return (ok||mod==0)&&mod2;
int &res=dp[idx][tight][ok][mod][mod2];
if(~res)return res;
res=0;
int x=s[idx]-'0';
int r=tight?x:9;
for(int i=0;i<=r;i++){
res+=dfs(idx+1,tight&&i==r,ok||i==3,(mod*10+i)%3,(mod2*10+i)%8);
res%=M;
}
return res;
}
main(){
memset(dp,-1,sizeof(dp));
cin>>s>>t;
int A=dfs(0);
swap(s,t);
memset(dp,-1,sizeof(dp));
int B=dfs(0);
r(i,t.size()){
sum=(sum*10+(t[i]-'0'))%24;
if(t[i]=='3')f=1;
}
f=(f||sum%3==0)&&(sum%8);
cout<<(B-A+M+f)%M<<endl;
}
C7C7LL