QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#16054 | #1842. Math | misaka18931 | RE | 2ms | 27828kb | C++14 | 1.9kb | 2021-11-17 10:07:59 | 2022-05-03 22:45:15 |
Judging History
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
*/
Details
Tip: Click on the bar to expand more detailed information
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