結果

問題 No.260 世界のなんとか3
ユーザー C7C7LLC7C7LL
提出日時 2018-07-26 13:51:39
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 184 ms / 2,000 ms
コード長 769 bytes
コンパイル時間 1,454 ms
コンパイル使用メモリ 145,548 KB
実行使用メモリ 11,752 KB
最終ジャッジ日時 2023-09-13 18:39:31
合計ジャッジ時間 5,337 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
10,876 KB
testcase_01 AC 6 ms
10,848 KB
testcase_02 AC 6 ms
10,844 KB
testcase_03 AC 183 ms
11,724 KB
testcase_04 AC 183 ms
11,752 KB
testcase_05 AC 38 ms
11,148 KB
testcase_06 AC 28 ms
11,032 KB
testcase_07 AC 130 ms
11,600 KB
testcase_08 AC 89 ms
11,572 KB
testcase_09 AC 51 ms
11,240 KB
testcase_10 AC 142 ms
11,464 KB
testcase_11 AC 132 ms
11,680 KB
testcase_12 AC 82 ms
11,552 KB
testcase_13 AC 27 ms
11,008 KB
testcase_14 AC 121 ms
11,656 KB
testcase_15 AC 35 ms
11,180 KB
testcase_16 AC 105 ms
11,400 KB
testcase_17 AC 83 ms
11,292 KB
testcase_18 AC 81 ms
11,220 KB
testcase_19 AC 105 ms
11,628 KB
testcase_20 AC 74 ms
11,312 KB
testcase_21 AC 66 ms
11,372 KB
testcase_22 AC 120 ms
11,480 KB
testcase_23 AC 16 ms
10,956 KB
testcase_24 AC 94 ms
11,492 KB
testcase_25 AC 94 ms
11,680 KB
testcase_26 AC 93 ms
11,656 KB
testcase_27 AC 6 ms
10,840 KB
testcase_28 AC 180 ms
11,680 KB
testcase_29 AC 184 ms
11,676 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[10003][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