QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#605792 | #9225. Fibonacci Fusion | ucup-team3215# | WA | 117ms | 315556kb | C++23 | 1.6kb | 2024-10-02 19:38:10 | 2024-10-02 19:38:10 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll k = 3;
constexpr array<ll, k> mod{(ll) 1e9 + 7, 998244353, (ll) 1e6 + 3};
int main() {
cin.tie(0)->sync_with_stdio(false);
constexpr ll N = 1e7;
ld phi = log10((1 + sqrtl(5)) / 2);
vector<array<ll, k + 1>> fib(N);
fib[1] = fib[0] = {1, 1, 1, 1};
for (int i = 2; i < N; ++i) {
fib[i][0] = (int) (i * phi);
for (int j = 1; j <= k; ++j) {
fib[i][j] = (fib[i - 1][j] + fib[i - 2][j]) % mod[j - 1];
}
}
ll n;
cin >> n;
vector<string> a(n);
for (auto &i: a)cin >> i;
sort(a.begin(), a.end(), [&](const string &s, const string &t) {
if (s.size() != t.size())return s.size() < t.size();
return s < t;
});
map<array<ll, k>, ll> cnt;
ll res=0;
for (auto &x: a) {
array<ll, k> rem{};
for (int i = 0; i < k; ++i) {
ll cur = 0;
for (auto c: x) {
cur = (cur * 10 + (c - '0')) % mod[i];
}
rem[i] = cur;
}
auto it = lower_bound(fib.begin(), fib.end(), array<ll, 4>{(ll) x.size() - 5, 0, 0, 0});
for (int j = 0; j < 15 && it != fib.end(); ++j, ++it) {
auto &v = *it;
array<ll, k> need{};
for(int i = 0;i < k;++i){
need[i] = (v[i + 1]-rem[i])%mod[i];
if(need[i] < 0)need[i] += mod[i];
}
res += cnt[need];
}
cnt[rem]++;
}
cout << res;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 117ms
memory: 315556kb
input:
6 50 8 8 5 72 354224848179261915070
output:
3
result:
wrong answer 1st numbers differ - expected: '4', found: '3'