結果
| 問題 |
No.1653 Squarefree
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-08-20 23:25:21 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,229 bytes |
| コンパイル時間 | 3,107 ms |
| コンパイル使用メモリ | 197,316 KB |
| 最終ジャッジ日時 | 2025-01-24 00:39:07 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 WA * 5 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
long long L, R;
cin >> L >> R;
vector<int> fac(1000010);
iota(fac.begin(), fac.end(), 0);
for(int i = 2; i < 1000010; i++){
if(fac[i] != i) continue;
for(int j = i * 2; j < 1000010; j += i){
fac[j] = i;
}
}
vector<long long> t(R - L + 1);
vector<long long> temp;
vector<int> num(R - L + 1);
iota(t.begin(), t.end(), L);
for(int i = 2; i <= 1000010; i++){
if(fac[i] != i) continue;
for(long long j = (L + i - 1) / i * i; j <= R; j += i){
int cnt = 0;
while(t[j - L] % i == 0){
t[j - L] /= i;
cnt++;
}
if(cnt > 1) num[j - L] = -1;
}
}
for(int i = 0; i < R - L + 1; i++){
if(num[i] == 0) temp.push_back(L + i);
}
int ans = temp.size();
for(int i = 0; i < (int)temp.size(); i++){
long long ub = 1000000000, lb = 0;
while(ub - lb > 1){
long long mid = (ub + lb) / 2;
if(mid * mid >= t[temp[i] - L]) ub = mid;
else lb = mid;
}
if(ub != 1 && ub * ub == t[i]) ans++;
}
cout << ans << endl;
}