結果

問題 No.260 世界のなんとか3
ユーザー C7C7LLC7C7LL
提出日時 2018-07-26 13:49:17
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 766 bytes
コンパイル時間 1,457 ms
コンパイル使用メモリ 145,980 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-13 18:39:13
合計ジャッジ時間 2,947 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 3 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:23:6: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
 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[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;
}
0