QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#16054#1842. Mathmisaka18931RE 2ms27828kbC++141.9kb2021-11-17 10:07:592022-05-03 22:45:15

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:15]
  • 评测
  • 测评结果:RE
  • 用时:2ms
  • 内存:27828kb
  • [2021-11-17 10:07:59]
  • 提交

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);
  }
  FOR(i, 1, mx + 1) assert(vis[i]);
  cerr << mx << '\n';
  i64 ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (auto v : g[a[i]]) {
      int A = a[i] / v - v;
      if (A <= 0) break;
      if (A & 1) continue;
      A >>= 1;
      if (vis[A]) ++ans;
    }
  }
  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: 27200kb

input:

5
1 2 3 4 5

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 1ms
memory: 27828kb

input:

1
1

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: -100
Dangerous Syscalls

input:

5
6 4 7 3 5

output:


result: