QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#655030#9225. Fibonacci Fusionreal_sigma_team#Compile Error//C++231.9kb2024-10-18 23:52:492024-10-18 23:52:50

Judging History

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

  • [2024-10-18 23:52:50]
  • 评测
  • [2024-10-18 23:52:49]
  • 提交

answer

#include<bits/stdc++.h>

int64_t mod = 1836311903;
int64_t mod2 = 1836311903;

const int K = 2200;

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

std::vector<int64_t> st, hsh;

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

    {
        int64_t a = 0, b = 1;
        st = {a, b};
        for (int i = 0; i < 1000; ++i) {
            int64_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());
    }

    {
        mod = (1ll << 61) - 1;
        int64_t a = 0, b = 1;
        hsh = {a, b};
        for (int i = 0; i < 1e7; ++i) {
            int64_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::map<int64_t, std::map<int64_t, int>> mp;
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        std::string s;
        std::cin >> s;
        int64_t h1 = 0, h2 = 0;
        for (auto x : s) {
            uint64_t h12 = add(h1, h1);
            uint64_t h14 = add(h12, h12);
            uint64_t h18 = add(h14, h14);
            h1 = add(add(h18, h12), x - '0');
            h2 = (h2 * 10 + (x - '0')) % mod2;
        }
        for (auto h : st) {
            int64_t need = h - h2;
            if (need < 0) need += mod2;
            for (auto [h3, w] : mp[need]) {
                ans += std::binary_search(hsh.begin(), hsh.end(), add(h1, h3)) * w;
            }
        }
        mp[h2][h1]++;
    }
    std::cout << ans << '\n';
}

详细

answer.code: In function ‘int main()’:
answer.code:52:5: error: ‘ll’ was not declared in this scope
   52 |     ll ans = 0;
      |     ^~
answer.code:68:17: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   68 |                 ans += std::binary_search(hsh.begin(), hsh.end(), add(h1, h3)) * w;
      |                 ^~~
      |                 abs
answer.code:73:18: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   73 |     std::cout << ans << '\n';
      |                  ^~~
      |                  abs