結果
| 問題 |
No.3101 Range Eratosthenes Query
|
| コンテスト | |
| ユーザー |
ha_chan
|
| 提出日時 | 2025-05-23 17:38:40 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 685 ms / 3,000 ms |
| コード長 | 1,121 bytes |
| コンパイル時間 | 4,354 ms |
| コンパイル使用メモリ | 254,784 KB |
| 実行使用メモリ | 55,888 KB |
| 最終ジャッジ日時 | 2025-05-23 17:39:01 |
| 合計ジャッジ時間 | 19,382 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 24 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<VL> VVL;
typedef long long LL;
#define all(a) (a).begin(), (a).end()
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#include <atcoder/all>
using namespace atcoder;
int op(int a, int b) { return a+ b; } //演算
int e() { return 0; } //単位元
int main() {
int n;cin>>n;
int ans[n];
int m=1000000;
VVI A[m+1];
rep(i,n){
int l,r;cin>>l>>r;
A[l].pb({r,i});
}
int S[m+1];
segtree<int,op,e> seg(m+1);
rep(i,m+1){
S[i]=1; seg.set(i,1);
}
for(int i=m;i>1;i--){
int p=i+i;
while(p<=m){
if(S[p]==1){
S[p]=0;
seg.set(p,0);
}
p+=i;
}
for(VI z : A[i]){
ans[z[1]]=seg.prod(i,z[0]+1);
}
}
for(VI z : A[1]){ans[z[1]]=1;}
rep(i,n){cout<<ans[i]<<endl;}
}
ha_chan