QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#468618 | #3395. 数表 | little_sun | 100 ✓ | 312ms | 11760kb | C++14 | 2.4kb | 2024-07-08 21:51:41 | 2024-07-08 21:51:41 |
Judging History
answer
#include <bits/stdc++.h>
#define R register
#define ll long long
#define sum(a, b, mod) (((a) + (b)) % mod)
#define meow(cat...) fprintf(stderr, cat)
const ll MaxN = 1e5 + 10;
struct query
{
ll n, m, a, id;
} Q[MaxN];
std::pair<ll, ll> p[MaxN];
ll q, cnt, pr[MaxN], vis[MaxN];
ll c[MaxN], g[MaxN], mu[MaxN], ans[MaxN];
ll lowbit(ll x) { return x & (-x); }
ll cmp(query a, query b) { return a.a < b.a; }
void add(ll x, ll v)
{
while(x < MaxN)
c[x] += v, x += lowbit(x);\
}
ll qry(ll x)
{
ll res = 0;
while(x)
res += c[x], x -= lowbit(x);
return res;
}
ll qry(ll l, ll r) { return qry(r) - qry(l - 1); }
inline ll read()
{
ll x = 0;
char ch = getchar();
while (ch > '9' || ch < '0')
ch = getchar();
while (ch <= '9' && ch >= '0')
x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
return x;
}
ll solve(ll n, ll m)
{
ll res = 0;
for(ll l = 1, r; l <= std::min(n, m); l = r + 1)
{
r = std::min(n / (n / l), m / (m / l));
res += qry(l, r) * (n / l) * (m / l);
}
return res;
}
void init()
{
mu[1] = 1;
for(ll i = 2; i < MaxN; i++)
{
if(!vis[i]) pr[++cnt] = i, mu[i] = -1;
for(ll j = 1; j <= cnt && i * pr[j] < MaxN; j++)
{
vis[i * pr[j]] = 1;
if(i % pr[j] == 0) break;
mu[i * pr[j]] = -mu[i];
}
}
for(ll i = 1; i < MaxN; i++)
{
for(ll j = 1; j * j <= i; j++)
if(i % j == 0)
{
p[i].first += j;
if(j * j != i)
p[i].first += i / j;
}
p[i].second = i;
}
std::sort(p + 1, p + MaxN);
}
signed main()
{
q = read(), init();
for(ll i = 1; i <= q; i++)
Q[i].n = read(), Q[i].m = read(), Q[i].a = read(), Q[i].id = i;
std::sort(Q + 1, Q + q + 1, cmp);
for(ll i = 1, now = 1; i <= q; i++)
{
while(p[now].first <= Q[i].a && now < MaxN)
{
for(ll k = p[now].second; k < MaxN; k += p[now].second)
add(k, p[now].first * mu[k / p[now].second]);
now = now + 1;
}
ans[Q[i].id] = solve(Q[i].n, Q[i].m);
}
for(ll i = 1; i <= q; i++)
printf("%lld\n", ans[i] % (1ll << 31));
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 10
Accepted
time: 78ms
memory: 9508kb
input:
200 267 104 40 380 84 127 86 252 155 42 99 111 304 236 640 274 313 332 208 74 34 71 55 38 373 218 260 157 188 203 116 54 23 59 33 41 250 71 51 338 64 2 356 319 746 23 193 13 188 352 307 239 23 33 3 347 2 56 103 122 322 170 181 242 228 144 198 29 32 6 366 3 263 273 629 356 247 270 313 386 196 295 224...
output:
89315 139738 95201 15953 381494 436088 46980 12075 402699 135769 16282 6168 60642 13251 631174 9876 332294 16585 753 23044 252771 244704 17575 2582 386818 438578 570942 339611 236294 115502 294326 562361 160559 53738 370650 134786 265013 69800 519331 1747 527702 59913 1113 479804 418675 51757 274636...
result:
ok 200 lines
Test #2:
score: 10
Accepted
time: 82ms
memory: 8544kb
input:
200 318 243 655 377 338 50 56 248 7 150 57 25 205 100 138 203 372 201 221 387 311 74 30 10 91 319 89 83 68 127 14 337 9 291 314 404 173 369 157 83 70 96 100 274 65 137 28 36 121 248 234 1 321 1 102 12 25 120 46 97 398 59 64 71 350 100 80 74 184 289 108 147 106 207 49 70 296 88 358 16 20 183 368 173 ...
output:
412430 436147 24546 23896 89137 355705 433179 4173 113869 22630 8979 479738 285360 22581 101614 12069 141968 321 3312 21719 86048 101684 24674 139329 75090 81009 15145 307968 9241 100051 292365 481835 517567 137283 212104 532631 70586 190228 693189 32190 51721 383443 51950 673550 150999 38173 254995...
result:
ok 200 lines
Test #3:
score: 10
Accepted
time: 78ms
memory: 9416kb
input:
200 297 8 16 129 379 68 173 387 260 373 253 113 248 100 126 319 256 111 158 149 237 294 173 213 146 106 311 372 273 637 277 169 81 292 297 123 356 21 2 37 394 74 32 193 57 57 64 39 199 221 363 292 115 219 170 212 211 154 135 238 302 11 24 57 303 156 143 210 386 216 198 515 141 229 64 117 285 333 348...
output:
5925 180664 329541 394292 107439 340574 109292 239339 70504 554254 180751 369592 4650 54474 21329 11608 220899 156276 168637 96474 8723 72268 146062 220424 118850 158946 129200 231515 108208 86419 31741 133766 381578 16765 129217 20370 148273 391958 387606 158500 72691 254339 6854 84749 137571 49029...
result:
ok 200 lines
Test #4:
score: 10
Accepted
time: 89ms
memory: 9580kb
input:
9 41975 27635 76493 13671 98458 40832 28983 35981 60418 5233 88325 2424 74788 44443 73821 33542 42950 29170 74446 86172 32221 63382 38706 93018 57252 80709 80709
output:
965895102 58727819 1877532847 1206131505 376975514 1018097782 640421735 1966317171 1611564655
result:
ok 9 lines
Test #5:
score: 10
Accepted
time: 89ms
memory: 8520kb
input:
9 41975 27635 76493 13671 98458 40832 28983 35981 60418 5233 88325 2424 74788 44443 73821 33542 42950 29170 74446 86172 32221 63382 38706 93018 57252 80709 80709
output:
965895102 58727819 1877532847 1206131505 376975514 1018097782 640421735 1966317171 1611564655
result:
ok 9 lines
Test #6:
score: 10
Accepted
time: 89ms
memory: 9416kb
input:
9 41975 27635 76493 13671 98458 40832 28983 35981 60418 5233 88325 2424 74788 44443 73821 33542 42950 29170 74446 86172 32221 63382 38706 93018 57252 80709 80709
output:
965895102 58727819 1877532847 1206131505 376975514 1018097782 640421735 1966317171 1611564655
result:
ok 9 lines
Test #7:
score: 10
Accepted
time: 201ms
memory: 9816kb
input:
10000 41975 27635 76493 13671 98458 40832 28983 35981 60418 5233 88325 2424 74788 44443 73821 33542 42950 29170 74446 86172 32221 63382 38706 93018 57252 80709 80709 14659 24433 24203 78208 82759 104175 89126 12782 6824 51620 41764 105296 50575 46997 91629 5894 38136 4223 11340 71677 16109 84609 624...
output:
965895102 58727819 1877532847 1206131505 376975514 1018097782 640421735 1966317171 1611564655 1197838105 1051229160 842989317 1044017255 1295673352 1752004802 961718591 1565760684 856738730 112565892 274788314 893518530 972871127 1919985233 1508191259 1553567777 1398690105 434598550 2098462435 20537...
result:
ok 10000 lines
Test #8:
score: 10
Accepted
time: 308ms
memory: 11760kb
input:
20000 41975 27635 76493 13671 98458 40832 28983 35981 60418 5233 88325 2424 74788 44443 73821 33542 42950 29170 74446 86172 32221 63382 38706 93018 57252 80709 80709 14659 24433 24203 78208 82759 104175 89126 12782 6824 51620 41764 105296 50575 46997 91629 5894 38136 4223 11340 71677 16109 84609 624...
output:
965895102 58727819 1877532847 1206131505 376975514 1018097782 640421735 1966317171 1611564655 1197838105 1051229160 842989317 1044017255 1295673352 1752004802 961718591 1565760684 856738730 112565892 274788314 893518530 972871127 1919985233 1508191259 1553567777 1398690105 434598550 2098462435 20537...
result:
ok 20000 lines
Test #9:
score: 10
Accepted
time: 308ms
memory: 10024kb
input:
20000 38183 50215 27907 31520 85221 80165 67003 87523 195294 12495 52666 838 45676 85712 49635 35300 84565 28063 80786 2798 7927 50832 94667 49849 96532 59755 28964 11445 84042 32009 38664 38577 60142 13527 70096 16755 92444 53450 79913 94367 65944 180246 26657 27971 32561 47663 79623 43656 79877 60...
output:
1288387801 2000430672 1881546482 1922179524 1243822922 926800076 1823322369 1886272285 178501330 484614503 141997177 93155707 736295010 1514915468 745820841 1740416584 673504814 1709571518 358777902 866688756 2126065286 266426204 1274735879 1094309923 662768295 560202577 306781398 1110977843 1652065...
result:
ok 20000 lines
Test #10:
score: 10
Accepted
time: 312ms
memory: 9324kb
input:
20000 25291 26958 42646 68543 80245 173646 67216 738 1486 73970 22960 13937 15434 57170 31512 49420 35827 32310 42266 15795 37484 99410 13666 8634 85989 60600 39032 83708 89127 84756 7733 30769 16251 928 99311 1846 91324 66526 164584 52287 40495 105337 27903 72280 38653 52171 21700 36455 30683 80317...
output:
235628669 9618953 330038694 221732787 2031452607 100240429 2136344378 816987651 488163074 21949673 2125961648 634947626 1968610255 599197986 695670283 354605107 959035126 1103518569 64743499 751964574 298611199 969030053 2008965948 708749598 672563356 347314884 1491990975 1538538608 820125570 118247...
result:
ok 20000 lines