QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#770048#9225. Fibonacci Fusionsleepy_shadowTL 164ms290128kbC++141.2kb2024-11-21 20:24:442024-11-21 20:24:45

Judging History

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

  • [2024-11-21 20:24:45]
  • 评测
  • 测评结果:TL
  • 用时:164ms
  • 内存:290128kb
  • [2024-11-21 20:24:44]
  • 提交

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 :: 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 + 40); ++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: 100
Accepted
time: 81ms
memory: 278956kb

input:

6
50
8
8
5
72
354224848179261915070

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 0
Accepted
time: 87ms
memory: 279380kb

input:

28
200878223506436882933619847964496455022155117513398820563747455993172799881403389571477889821109288771413214004090719097929400406252135763028179112130390003528046316900603668569910008417315162907579003880220844686222148696041857432602133894827753998572080650383305777912447151917272483538029469449...

output:

27

result:

ok 1 number(s): "27"

Test #3:

score: 0
Accepted
time: 164ms
memory: 290128kb

input:

5187
2640352926124261912741724778991366987330659389621881876017670644497364093930668042530271338851702874394631009332660937266680740235862107353443518003194307853104942996827176097428402408674756368623972812842571069642405111849826172879369776309763468485788964245903781380419155348915131587410703749...

output:

6073

result:

ok 1 number(s): "6073"

Test #4:

score: 0
Accepted
time: 121ms
memory: 280612kb

input:

200000
2
2
2
2
1
2
1
1
2
2
1
1
1
2
2
1
1
2
1
1
2
2
1
2
2
2
1
1
1
1
2
2
1
2
1
2
1
1
2
2
1
1
1
2
1
1
2
1
2
2
2
2
1
2
2
1
1
1
2
1
1
1
1
1
2
1
2
2
1
1
1
2
2
2
1
1
2
1
1
2
1
2
1
1
1
2
2
2
1
1
1
1
2
1
2
1
1
2
2
1
1
2
1
1
2
1
2
2
1
2
1
2
2
1
1
2
1
1
1
2
2
2
1
2
2
1
1
2
2
2
2
1
2
1
1
2
1
2
2
1
1
1
1
2
2
2
2...

output:

15003749259

result:

ok 1 number(s): "15003749259"

Test #5:

score: -100
Time Limit Exceeded

input:

200000
944176313232170622314
2590599414036674999101
753315073608896000424
9299685298577430049245
9361800333778142620806
8988699166328904060999
9606920674025578304023
4203331868598952026136
5183047027116137697788
3968714342776915029801
8130984095583566992354
3206443643596048048798
6248561214283254355...

output:


result: