QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#770129 | #9225. Fibonacci Fusion | sleepy_shadow | RE | 0ms | 0kb | C++14 | 1.2kb | 2024-11-21 20:47:46 | 2024-11-21 20:47:46 |
answer
#include <bits/stdc++.h>
#define ld long double
#define ll long long
const int N = 2e5 + 5, M = 1e7;
const ll P = 1e18, mod = 1e17 + 9;
int n, k[M + 10];
ll f[M + 10], res;
ld d[M + 10];
char s[2000020];
struct node {
int n;
ll x;
} a[N];
std :: unordered_map<ll, int> mp;
ll sub(ll x, ll y) {
return x < y ? x - y + mod : x - y;
}
int main() {
freopen ("a.out", "w", stdout);
f[0] = f[1] = d[0] = d[1] = 1;
k[0] = k[1] = 0;
for (int i = 2; i <= M; ++i) {
f[i] = (f[i - 1] + f[i - 2]) % mod;
d[i] = (k[i - 2] == k[i - 1] ? d[i - 2] : d[i - 2] / 10) + d[i - 1];
k[i] = k[i - 1];
if (d[i] >= 10) d[i] /= 10, ++k[i];
}
scanf ("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf ("%s", s + 1);
a[i].n = strlen(s + 1);
for (int j = 1; j <= a[i].n; ++j) a[i].x = (a[i].x * 10 + s[j] - '0') % mod;
}
std :: sort(a + 1, a + n + 1, [](node a, node b) { return a.n < b.n; });
int j = 2;
for (int i = 1; i <= n; ++i) {
while (1 + k[j] < a[i].n) ++j;
ll v = a[i].x;
for (int t = j; t <= std :: min(M, j + 5); ++t) res += mp[sub(f[t], v)];
++mp[v];
}
printf ("%lld\n", res);
return 0;
}
详细
Test #1:
score: 0
Dangerous Syscalls
input:
6 50 8 8 5 72 354224848179261915070