QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#16053#1842. Mathmisaka18931TL 50ms36280kbC++141.9kb2021-11-17 09:51:182022-05-03 22:45:10

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-03 22:45:10]
  • 评测
  • 测评结果:TL
  • 用时:50ms
  • 内存:36280kb
  • [2021-11-17 09:51:18]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
template<typename T>
void rd(T &a) {
  cin >> a;
}
template<typename A, typename... B>
void rd(A &a, B& ...b) {
  cin >> a;
  rd(b...);
}
template<typename A>
void print(const A& a) {
  cout << a;
}
template<typename A, typename... B>
void print(const A& a, const B& ...b) {
  cout << a;
  print(b...);
}
template<typename A>
void println(const A& a) {
  cout << a << '\n';
}
template<typename A, typename... B>
void println(const A& a, const B& ...b) {
  cout << a << ' ';
  println(b...);
}
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int, int> pii;
#define mkp make_pair
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define FOR(i, j, k) for (int i = (j); i < (k); ++i)
#define ROF(i, j, k) for (int i = ((k) - 1); i >= j; --i)
template<typename T>
inline void chkmin(T &a, const T b) {
  a = min(a, b);
}
template<typename T>
inline void chkmax(T &a, const T b) {
  a = max(a, b);
}

const int N = 1e6+5;
i64 ans = 0;
vector<int> g[N];
bool vis[N];
int a[N], mx;
int n;

inline void solve() {
  cin >> n;
  FOR(i, 1, n + 1) cin >> a[i], chkmax(mx, a[i]), vis[a[i]] = 1;
  FOR(i, 1, mx +1 ) for (int j = i; j <= mx; j +=i) {
    g[j].pb(i);
  }
  i64 ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (auto v : g[a[i]]) {
      if (v * v >= a[i]) break;
      int A = a[i] / v - v;
      if (A & 1) continue;
      A >>= 1;
      ans += vis[A];
    }
  }
  println(ans);
}

int main() {
#ifndef MISAKA
  //freopen(".in", "r", stdin);
  //freopen(".out", "w", stdout);
  ios::sync_with_stdio(0);
  cin.tie(0);
#endif
  solve();
  return 0;
}
/* Checklist:
 * - data type
 * - overflow
 * - typo/logic
 * - special cases
 * - cleanup (multi-test)
 * - bounds
 * - memory usage
 * - file IO
 */


詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 27532kb

input:

5
1 2 3 4 5

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 2ms
memory: 28744kb

input:

1
1

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: 0
Accepted
time: 2ms
memory: 27404kb

input:

5
6 4 7 3 5

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 6ms
memory: 27412kb

input:

50
89 2 3 86 81 59 29 26 28 8 48 5 6 95 54 91 17 83 4 36 15 43 92 70 30 37 23 96 39 80 9 90 49 82 33 71 61 38 99 50 65 47 78 45 68 7 25 42 13 57

output:

29

result:

ok 1 number(s): "29"

Test #5:

score: 0
Accepted
time: 8ms
memory: 28952kb

input:

1000
662 811 263 46 591 511 230 223 628 603 716 880 187 575 701 184 505 754 130 154 367 91 704 945 171 588 19 486 34 513 622 849 629 437 776 290 743 470 587 681 723 271 879 642 77 281 71 655 365 942 809 94 266 148 146 305 198 311 788 69 343 277 887 557 169 41 784 791 451 812 932 663 594 576 487 946 ...

output:

1750

result:

ok 1 number(s): "1750"

Test #6:

score: 0
Accepted
time: 8ms
memory: 28212kb

input:

10000
2246 4941 6031 8713 4705 3744 9374 9432 2502 7080 8851 5408 4724 8905 7565 1699 6660 8959 7798 2287 4610 8806 8128 451 1355 2111 8775 4903 7517 8983 8144 2578 9565 7332 3213 4943 6520 616 2559 5573 6391 7148 5121 8395 5618 8733 6132 3717 8549 9651 1291 9462 5941 2342 9625 398 3916 8586 4290 26...

output:

23368

result:

ok 1 number(s): "23368"

Test #7:

score: 0
Accepted
time: 50ms
memory: 36280kb

input:

100000
94437 49936 62522 1166 33452 90618 91436 81173 99242 37280 46125 44869 52811 45694 11550 29857 48941 56538 35057 40907 79925 70785 29658 19044 32804 11428 4127 92197 12680 61636 27200 56790 83389 80340 54411 15308 38952 78085 81397 37554 44186 33581 35662 73331 84991 32044 69012 82289 63495 6...

output:

291528

result:

ok 1 number(s): "291528"

Test #8:

score: -100
Time Limit Exceeded

input:

1000000
287979 230793 805881 397585 695359 701731 296206 140797 257828 646397 649020 775370 622178 482759 161855 499413 690372 463229 541524 906954 116709 106321 17736 555558 848745 804067 532778 605445 239082 752084 465207 248311 821443 697678 323802 224937 607056 905999 886110 635290 199168 451068...

output:


result: