結果

問題 No.260 世界のなんとか3
ユーザー C7C7LL
提出日時 2018-07-26 13:50:45
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
MLE  
実行時間 -
コード長 770 bytes
コンパイル時間 1,270 ms
コンパイル使用メモリ 159,604 KB
実行使用メモリ 79,436 KB
最終ジャッジ日時 2024-07-01 03:18:04
合計ジャッジ時間 5,678 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample MLE * 3
other MLE * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:23:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
   23 | main(){
      | ^~~~

ソースコード

diff #

#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;

int dp[100000][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;
}
0