QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#770129#9225. Fibonacci Fusionsleepy_shadowRE 0ms0kbC++141.2kb2024-11-21 20:47:462024-11-21 20:47:46

Judging History

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

  • [2024-11-21 20:47:46]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Dangerous Syscalls

input:

6
50
8
8
5
72
354224848179261915070

output:


result: