QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#563166 | #6145. 数对 | elegia | 100 ✓ | 17ms | 7240kb | C++14 | 2.5kb | 2024-09-14 03:14:59 | 2024-09-14 18:30:26 |
Judging History
answer
/*
_/_/_/_/ _/_/_/_/_/ _/_/_/
_/ _/ _/ _/ _/
_/ _/ _/ _/ _/
_/ _/ _/ _/ _/
_/ _/ _/ _/ _/ _/
_/ _/ _/ _/ _/ _/_/
_/_/_/_/ _/_/ _/_/_/_/_/
_/_/_/_/ _/ _/ _/ _/
_/ _/ _/ _/ _/_/ _/_/
_/ _/ _/_/ _/ _/_/ _/
_/ _/ _/ _/ _/ _/
_/ _/ _/_/ _/ _/
_/ _/ _/ _/ _/ _/
_/_/_/_/ _/ _/ _/ _/
_/_/_/_/_/ _/_/_/_/_/ _/_/_/_/_/
_/ _/ _/
_/ _/ _/
_/ _/ _/_/_/_/
_/ _/ _/
_/ _/ _/
_/ _/_/_/_/_/ _/_/_/_/_/
_/_/_/_/_/ _/_/_/_/_/ _/_/_/_/_/
_/ _/ _/
_/ _/ _/
_/ _/ _/_/_/_/
_/ _/ _/
_/ _/ _/
_/ _/_/_/_/_/ _/_/_/_/_/
*/
#include <cassert>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>
#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <iomanip>
#include <limits>
#include <numeric>
#define LOG(FMT...) fprintf(stderr, FMT)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
for (T& x : v)
is >> x;
return is;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
if (!v.empty()) {
os << v.front();
for (int i = 1; i < v.size(); ++i)
os << ' ' << v[i];
}
return os;
}
const int N = 500010;
int a[N], c[N];
bool f[N];
int main() {
#ifdef ELEGIA
freopen("test.in", "r", stdin);
int nol_cl = clock();
#endif
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
int m = 0;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
m = max(m, a[i]);
++c[a[i]];
}
for (int i = 2; i <= m; ++i) {
if (f[i]) continue;
for (int j = 1, k = i; k <= m; ++j, k += i) {
f[k] = true;
c[k] += c[j];
}
}
ull ans = 0;
for (int i = 1; i <= n; ++i) ans += c[a[i]];
ans -= n;
cout << ans << '\n';
#ifdef ELEGIA
LOG("Time: %dms\n", int ((clock()
-nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 1ms
memory: 5620kb
input:
1000 116 493 408 431 447 462 188 59 159 13 86 278 392 3 222 460 407 197 400 343 439 492 79 55 457 191 58 343 120 326 164 467 9 353 295 473 100 282 411 88 28 362 17 36 222 471 239 134 309 127 121 57 177 442 428 74 24 467 80 122 360 95 97 427 46 320 203 445 350 106 13 200 478 121 81 430 165 493 368 39...
output:
12173
result:
ok 1 number(s): "12173"
Test #2:
score: 10
Accepted
time: 0ms
memory: 5632kb
input:
1000 43 78 219 306 34 303 300 294 244 101 48 421 85 281 434 50 268 196 74 463 482 211 273 381 124 76 394 482 451 265 136 329 163 444 64 24 366 362 159 38 259 264 127 143 411 129 369 385 461 80 478 44 248 104 316 486 7 113 263 19 66 11 387 457 373 281 224 28 360 470 290 129 423 162 328 246 67 196 463...
output:
12201
result:
ok 1 number(s): "12201"
Test #3:
score: 10
Accepted
time: 0ms
memory: 5684kb
input:
1000 441 81 95 341 206 488 309 419 498 213 335 76 161 395 172 75 419 296 472 330 203 59 215 327 321 301 215 73 242 402 440 19 388 263 166 469 193 144 195 159 469 75 376 128 497 197 460 142 152 11 159 373 133 46 96 222 72 391 237 452 280 419 141 114 60 98 461 463 118 466 450 266 493 318 171 374 379 4...
output:
12966
result:
ok 1 number(s): "12966"
Test #4:
score: 10
Accepted
time: 1ms
memory: 5708kb
input:
1000 147 101 263 218 269 265 183 195 454 20 90 314 482 163 236 79 391 293 202 332 80 342 343 64 294 425 90 232 330 98 60 278 272 31 282 370 127 152 163 312 399 431 386 216 460 49 433 367 147 194 495 42 84 130 416 170 67 494 459 93 239 197 315 162 475 360 19 247 17 495 212 167 103 143 69 142 382 109 ...
output:
12881
result:
ok 1 number(s): "12881"
Test #5:
score: 10
Accepted
time: 9ms
memory: 5652kb
input:
200000 4464 3896 3597 3911 3080 2043 979 1941 4434 1721 1097 4071 1071 628 1357 1876 1705 3299 4274 4075 190 2016 3 2724 4524 4230 2725 39 4440 4679 335 1908 1132 2501 3199 1586 2769 4928 2168 2642 4091 701 4101 4236 4766 4935 608 1209 3120 2661 2459 3850 1408 1 3611 395 1882 1565 2512 3637 4587 344...
output:
68935556
result:
ok 1 number(s): "68935556"
Test #6:
score: 10
Accepted
time: 6ms
memory: 6044kb
input:
200000 1885 2058 2870 4471 2502 2231 4348 1871 3045 3837 3439 3283 3471 83 3307 4514 3370 2714 882 3193 4654 963 3326 1410 2628 4174 4782 4826 3324 3720 2139 1267 1321 4048 4460 3981 1980 1369 2635 1431 3782 3998 1143 3654 1693 1174 2408 2814 1121 3734 711 4391 1156 2815 2449 1925 2408 3539 4809 167...
output:
67658460
result:
ok 1 number(s): "67658460"
Test #7:
score: 10
Accepted
time: 9ms
memory: 6092kb
input:
200000 872 2366 2403 385 1135 4312 1122 2261 1417 4737 4939 414 1179 547 4664 1896 2582 4823 1078 4293 4267 4670 4028 4370 3344 4190 1195 3377 303 4841 2038 1156 2152 1309 2360 4226 1813 3605 1840 431 1852 1186 1642 786 4314 3169 2451 3230 4638 283 2695 1028 2295 640 2745 3318 3311 852 1228 4228 247...
output:
68456618
result:
ok 1 number(s): "68456618"
Test #8:
score: 10
Accepted
time: 17ms
memory: 6800kb
input:
200000 124602 198907 275876 98657 245724 446904 408253 450572 56410 358146 1077 90071 468989 20649 463986 446302 299408 7947 20463 336344 157650 22463 449076 413301 271493 452962 210027 122820 264727 253772 185214 183581 243178 158798 314024 112586 295942 263749 329668 481520 67399 4975 79502 386062...
output:
907926
result:
ok 1 number(s): "907926"
Test #9:
score: 10
Accepted
time: 16ms
memory: 6920kb
input:
200000 341252 127669 243178 162810 227121 360369 354147 306968 46188 91798 485660 144414 109618 430886 269620 467760 357952 235644 66034 70859 151660 362674 86879 333179 475289 369226 170365 175589 456355 221565 494064 358715 49654 334319 120057 343500 398359 211008 106899 245248 440147 371391 59021...
output:
1083881
result:
ok 1 number(s): "1083881"
Test #10:
score: 10
Accepted
time: 17ms
memory: 7240kb
input:
200000 93382 103811 355333 226343 289264 56049 289983 137453 148138 194416 307872 225170 67691 417237 417311 155051 342821 491600 449830 84099 121619 80499 126967 448346 139966 369838 464725 366431 204965 63478 121818 430600 456492 17177 118380 156394 411707 485116 495033 134937 373132 310328 498650...
output:
1233085
result:
ok 1 number(s): "1233085"