QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#746380#5587. Distinct Parity Excessi24TL 299ms18772kbC++141.2kb2024-11-14 14:26:252024-11-14 14:26:26

Judging History

你现在查看的是最新测评结果

  • [2024-11-14 14:26:26]
  • 评测
  • 测评结果:TL
  • 用时:299ms
  • 内存:18772kb
  • [2024-11-14 14:26:25]
  • 提交

answer

// File generated on 24/11/13 21:58 by Anand

#include <bits/stdc++.h>
using namespace std;

#define fastio ios::sync_with_stdio(false); cin.tie(0)
#define rep(i, m, n)  for (long long i = m; i < n; i++)
#define DEBUG(x) cout << "debug: " << x << "\n"
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define pb push_back
#define sz size

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vec;
typedef vector<vec> vecc;
typedef vector<pll> vecp;

ll f(ll n) {
    ll c = 0;
    if (n%2==0) c++;
    while(n%2==0) n/=2;

    for(ll i = 3; i <= sqrtl(n); i+=2) {
        if (n == 1) break;
        if (n%i==0) c++;
        while(n%i==0) n/=i;
    }

    if (n > 2) c++;

    return c;
}

ll N = 0;

void SOLVE() {
    ll n; cin >> n;
    vecp u(n);
    rep(i,0,n) {ll x, y; cin >> x >> y; u[i] = {x,y}; N = max(N, y);}
    N++;
    vec a(N);
    vec b(N);
    rep(i,2,N) {
        if (f(i)&1) {b[i] = b[i-1] + 1; a[i] = a[i-1];}
        else {a[i] = a[i - 1] + 1; b[i] = b[i-1];}
    }

    rep(i,0,n) {
        ll l = u[i].first;
        ll r = u[i].second;
        cout << a[r] - a[l - 1] - b[r] + b[l - 1] << "\n";
    }
}

signed main() {
    fastio;


		SOLVE();

    return 0;
}


詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3664kb

input:

3
2 2
2 5
2 10

output:

-1
-4
-5

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 299ms
memory: 18772kb

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: 271ms
memory: 17772kb

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: -100
Time Limit Exceeded

input:

10
5029986 7710504
2780724 8715606
1124900 1304897
1391064 2877235
6811377 8645635
3609999 9999334
3611675 6616197
3599993 6888463
4602820 8926934
948628 1015372

output:


result: