QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#655007#9225. Fibonacci Fusionreal_sigma_team#WA 42ms11880kbC++171.8kb2024-10-18 23:43:032024-10-18 23:43:04

Judging History

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

  • [2024-10-18 23:43:04]
  • 评测
  • 测评结果:WA
  • 用时:42ms
  • 内存:11880kb
  • [2024-10-18 23:43:03]
  • 提交

answer

#include<bits/stdc++.h>

uint64_t mod = 1836311903ull * 433494437;
uint64_t mod2 = 1836311903ull * 433494437;

const int K = 2200;

uint64_t add(uint64_t a, uint64_t b) {
    return a + b >= mod ? a + b - mod : a + b;
}
uint64_t sub(uint64_t a, uint64_t b) {
    return a >= b ? a - b : a + mod - b;
}
uint64_t mul(uint64_t a, uint64_t b) {
    return 1ll * a * b % mod;
}

std::vector<uint64_t> st, hsh;

int main() {
    std::cin.tie(nullptr)->sync_with_stdio(false);

    {
        uint64_t a = 0, b = 1;
        st = {a, b};
        for (int i = 0; i < 1e6; ++i) {
            uint64_t c = add(a, b);
            st.push_back(c);
            a = b;
            b = c;
        }
        std::sort(st.begin(), st.end());
        st.resize(std::unique(st.begin(), st.end()) - st.begin());
    }
    std::cout << st.size() << std::endl;

//    {
//        mod = (1ll << 61) - 1;
//        uint64_t a = 0, b = 1;
//        hsh = {a, b};
//        for (int i = 0; i < 1e7; ++i) {
//            uint64_t c = add(a, b);
//            hsh.push_back(c);
//            a = b;
//            b = c;
//        }
//        std::sort(hsh.begin(), hsh.end());
//    }

    int n;
    std::cin >> n;
    std::unordered_map<uint64_t, int> mp;
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
        std::string s;
        std::cin >> s;
        uint64_t h = 0;
        for (auto x : s) {
            uint64_t h2 = add(h, h);
            uint64_t h4 = add(h2, h2);
            uint64_t h8 = add(h4, h4);
            h = add(add(h8, h2), x - '0');
        }
        for (auto x : st) {
            uint64_t need = sub(x, h);
            if (mp.find(need) != mp.end()) ans += mp[need];
        }
        mp[h]++;
    }
    std::cout << ans;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 42ms
memory: 11880kb

input:

6
50
8
8
5
72
354224848179261915070

output:

2914
4

result:

wrong answer 1st numbers differ - expected: '4', found: '2914'