結果
| 問題 | 
                            No.1567 Integer Coefficient Equation
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Nachia
                         | 
                    
| 提出日時 | 2021-06-26 14:47:37 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 995 bytes | 
| コンパイル時間 | 775 ms | 
| コンパイル使用メモリ | 73,624 KB | 
| 最終ジャッジ日時 | 2025-01-22 13:26:37 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | WA * 38 | 
ソースコード
#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){
  rep(t,2) for(int p = Z/x; p>0; p--) dp[t][p*x] = max(dp[t][p*x],dp[t][p]+1);
  rep(t,2) for(int p = Z/x; p>0; p--) 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[0] = 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;
            
            
            
        
            
Nachia