結果
| 問題 |
No.1567 Integer Coefficient Equation
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2021-06-26 14:50:06 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 141 ms / 2,000 ms |
| コード長 | 995 bytes |
| コンパイル時間 | 699 ms |
| コンパイル使用メモリ | 73,468 KB |
| 最終ジャッジ日時 | 2025-01-22 13:27:05 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 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){
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;
Nachia