QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#770138#9225. Fibonacci Fusionsleepy_shadowWA 96ms279124kbC++141.2kb2024-11-21 20:49:282024-11-21 20:49:28

Judging History

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

  • [2024-11-21 20:49:28]
  • 评测
  • 测评结果:WA
  • 用时:96ms
  • 内存:279124kb
  • [2024-11-21 20:49:28]
  • 提交

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() {
    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: 100
Accepted
time: 39ms
memory: 278056kb

input:

6
50
8
8
5
72
354224848179261915070

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 0
Accepted
time: 96ms
memory: 279124kb

input:

28
200878223506436882933619847964496455022155117513398820563747455993172799881403389571477889821109288771413214004090719097929400406252135763028179112130390003528046316900603668569910008417315162907579003880220844686222148696041857432602133894827753998572080650383305777912447151917272483538029469449...

output:

27

result:

ok 1 number(s): "27"

Test #3:

score: -100
Wrong Answer
time: 96ms
memory: 279096kb

input:

5187
2640352926124261912741724778991366987330659389621881876017670644497364093930668042530271338851702874394631009332660937266680740235862107353443518003194307853104942996827176097428402408674756368623972812842571069642405111849826172879369776309763468485788964245903781380419155348915131587410703749...

output:

6071

result:

wrong answer 1st numbers differ - expected: '6073', found: '6071'