結果

問題 No.1567 Integer Coefficient Equation
ユーザー 👑 NachiaNachia
提出日時 2021-06-26 14:50:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 995 bytes
コンパイル時間 586 ms
コンパイル使用メモリ 75,640 KB
実行使用メモリ 11,012 KB
最終ジャッジ日時 2023-09-07 16:44:21
合計ジャッジ時間 6,649 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
10,904 KB
testcase_01 AC 58 ms
11,004 KB
testcase_02 AC 84 ms
10,848 KB
testcase_03 AC 84 ms
10,984 KB
testcase_04 AC 83 ms
10,744 KB
testcase_05 AC 83 ms
10,912 KB
testcase_06 AC 83 ms
10,848 KB
testcase_07 AC 59 ms
10,980 KB
testcase_08 AC 58 ms
10,916 KB
testcase_09 AC 58 ms
10,848 KB
testcase_10 AC 58 ms
10,844 KB
testcase_11 AC 58 ms
10,916 KB
testcase_12 AC 57 ms
10,740 KB
testcase_13 AC 58 ms
10,976 KB
testcase_14 AC 58 ms
10,992 KB
testcase_15 AC 58 ms
10,920 KB
testcase_16 AC 58 ms
10,736 KB
testcase_17 AC 99 ms
10,904 KB
testcase_18 AC 98 ms
11,012 KB
testcase_19 AC 100 ms
10,792 KB
testcase_20 AC 99 ms
10,912 KB
testcase_21 AC 96 ms
10,980 KB
testcase_22 AC 98 ms
10,972 KB
testcase_23 AC 100 ms
10,844 KB
testcase_24 AC 101 ms
10,792 KB
testcase_25 AC 101 ms
10,804 KB
testcase_26 AC 101 ms
10,732 KB
testcase_27 AC 100 ms
10,984 KB
testcase_28 AC 98 ms
10,916 KB
testcase_29 AC 98 ms
10,840 KB
testcase_30 AC 98 ms
10,916 KB
testcase_31 AC 97 ms
10,916 KB
testcase_32 AC 98 ms
10,900 KB
testcase_33 AC 100 ms
10,800 KB
testcase_34 AC 98 ms
10,980 KB
testcase_35 AC 98 ms
10,980 KB
testcase_36 AC 99 ms
10,908 KB
testcase_37 AC 95 ms
10,836 KB
testcase_38 AC 97 ms
10,912 KB
testcase_39 AC 92 ms
10,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

const int Z = 500001;

vector<int> dp[2];

void procdp(int x){
  for(int p = Z/x; p>0; p--) rep(t,2) dp[t][p*x] = max(dp[t][p*x],dp[t][p]+1);
  for(int p = Z/x; p>0; p--) rep(t,2) dp[t][p*x] = max(dp[t][p*x],dp[t^1][p]+1);
}

vector<int> X;

int main(){
  rep(t,2) dp[t].assign(Z+1,0);
  dp[0][1] = 2;
  dp[1][1] = 1;
  for(int x=2; x<=Z; x++) procdp(x);

  X.assign(Z*2+1,0);
  X[Z] = 1;
  for(int i=1; i<=Z; i++) X[Z-i] = ((dp[1][i] >= 5) ? 1 : 0);
  for(int i=1; i<=Z; i++) X[Z+i] = ((dp[0][i] >= 5) ? 1 : 0);
  rep(i,Z*2) X[i+1] += X[i];

  int T; cin >> T;
  while(T--){
    int p,l,r; cin >> p >> l >> r; l--;
    l -= p; r -= p;
    int ans = X[r+Z] - X[l+Z];
    cout << ans << "\n";
  }
  return 0;
}

struct ios_do_not_sync{
  ios_do_not_sync(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
  }
} ios_do_not_sync_inst;
0