QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#719143#9225. Fibonacci FusionstavageWA 72ms94076kbC++201.5kb2024-11-06 22:47:202024-11-06 22:47:21

Judging History

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

  • [2024-11-06 22:47:21]
  • 评测
  • 测评结果:WA
  • 用时:72ms
  • 内存:94076kb
  • [2024-11-06 22:47:20]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define int LL
#define double LD
const int N = 1e7 + 5;
const int M = 2e5 + 5;
const int MOD = 1e18 + 114559;
const double lgs = log((1.L + sqrtl(5)) / 2);

int n;
int fi[N];
string s[M];
int a[N];
map<int, int> mp;
int ans;
int calc(string s)
{
    double tog = 0;
    for (int i = s.size() - 1; i >= 0; i--) {
        tog *= 0.1;
        tog += s[i] - '0';
    }
    return (log(tog) + log(10) * (s.length() - 1)) / lgs;
}
void solve()
{
    fi[1] = 1;
    for (int i = 2; i <= 10000000; i++) fi[i] = (fi[i - 1] + fi[i - 2]) % MOD;

    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> s[i];
    }
    sort(s + 1, s + 1 + n, [&](string x, string y) {
      return x.length() == y.length() ? x < y : x.length() < y.length();
    });
    for (int i = 1; i <= n; i++) {
        a[i] = 0;
        for (int j = 0; j < s[i].length(); j++) {
            a[i] = (a[i] * 10 + s[i][j] - '0') % MOD;
        }
        int tmp = max(calc(s[i]) - 2, 2LL);
        for (int j = tmp; j <= tmp + 9; j++) {
            int r = (fi[j] + MOD - a[i]) % MOD;

            if (mp.count(r)) {
                ans += mp[r];
            }
        }
        mp[a[i]] += 1;
    }
    cout << ans << "\n";
}

signed main()
{
    cin.tie(nullptr)->ios::sync_with_stdio(false);
    int _ = 1;
    while (_--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 35ms
memory: 89180kb

input:

6
50
8
8
5
72
354224848179261915070

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: -100
Wrong Answer
time: 72ms
memory: 94076kb

input:

28
200878223506436882933619847964496455022155117513398820563747455993172799881403389571477889821109288771413214004090719097929400406252135763028179112130390003528046316900603668569910008417315162907579003880220844686222148696041857432602133894827753998572080650383305777912447151917272483538029469449...

output:

0

result:

wrong answer 1st numbers differ - expected: '27', found: '0'