QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#865339 | #5587. Distinct Parity Excess | LaVuna47# | AC ✓ | 124ms | 81856kb | C++20 | 1.8kb | 2025-01-21 16:51:13 | 2025-01-21 16:51:14 |
Judging History
answer
//A tree without skin will surely die.
//A man without face is invincible.
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(S) ((int)S.size())
#define FOR(i, st_, n) for(int i = st_; i < n; ++i)
#define RFOR(i, n, end_) for(int i = (n)-1; i >= end_; --i)
#define x first
#define y second
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef unsigned long long ull;
typedef long double LD;
typedef pair<ull, ull> pull;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using namespace std;
#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif
const int MAX_N=1e7+47;
int C[MAX_N];
int PC[MAX_N];
// 2 3 4 5 6 7 8 9 10
// 1 1 1 1 2 1 1 1 2
int solve()
{
int n;
if(!(cin>>n))return 1;
FOR(i,2,MAX_N)
{
if(C[i]!=0) continue;
for(int j=i; j < MAX_N; j += i)
C[j]+=1;
}
FOR(i,2,MAX_N)
{
PC[i]=PC[i-1];
if(C[i]%2==0)PC[i]+=1;
}
FOR(i,0,n)
{
int l, r;
cin>>l>>r;
cout<<(PC[r]-PC[l-1] - (r-l+1-(PC[r]-PC[l-1])))<<'\n';
}
return 0;
}
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int TET = 1e9;
//cin >> TET;
for (int i = 1; i <= TET; i++)
{
if (solve())
{
break;
}
#ifdef ONPC
cout << "__________________________" << endl;
#endif
}
#ifdef ONPC
cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
#endif
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 107ms
memory: 81720kb
input:
3 2 2 2 5 2 10
output:
-1 -4 -5
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 109ms
memory: 81856kb
input:
8 2 100 2 50 50 100 2 1000 100 143 2 1000000 80000 90000 1000000 1000000
output:
13 -1 15 63 0 -1909 -31 1
result:
ok 8 lines
Test #3:
score: 0
Accepted
time: 103ms
memory: 81852kb
input:
10 382245 819896 541000 940657 146832 465833 603509 801534 298623 379575 375605 402241 131337 581395 92899 271294 718706 825535 714017 861484
output:
-784 -608 -518 -88 -253 -41 -1067 -646 -386 -44
result:
ok 10 lines
Test #4:
score: 0
Accepted
time: 102ms
memory: 81692kb
input:
10 5029986 7710504 2780724 8715606 1124900 1304897 1391064 2877235 6811377 8645635 3609999 9999334 3611675 6616197 3599993 6888463 4602820 8926934 948628 1015372
output:
741 -383 -186 -416 -603 894 277 -153 -305 321
result:
ok 10 lines
Test #5:
score: 0
Accepted
time: 124ms
memory: 81856kb
input:
10 2038711 3100771 5100982 8330782 4186549 6595205 2745178 8582462 2990225 5249134 714917 4907291 2265159 8632136 1653054 5378313 3011697 7955156 7552410 9776486
output:
381 963 487 203 -382 -1069 -12 -836 -162 619
result:
ok 10 lines
Test #6:
score: 0
Accepted
time: 111ms
memory: 81736kb
input:
10 2825912 6331426 3371283 8994476 1852689 9530995 503251 2875846 1484762 4452738 2718118 7925568 8246970 9515925 551401 9338634 1219402 1788177 6627126 6835439
output:
181 382 -127 -1282 -147 307 -14 -1250 388 56
result:
ok 10 lines
Test #7:
score: 0
Accepted
time: 107ms
memory: 81852kb
input:
10 4511877 8376994 232714 4628307 5313897 6635021 1350661 6178784 3662577 7241422 1825460 9682385 1108136 5021151 728661 5585243 2193613 4398189 3150983 4600167
output:
312 -1500 1017 -274 -680 -254 -1332 -863 199 -149
result:
ok 10 lines
Test #8:
score: 0
Accepted
time: 123ms
memory: 81776kb
input:
3 2 10000000 2 1000000 2 100000
output:
-1651 -1909 -721
result:
ok 3 lines