QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#600424 | #9225. Fibonacci Fusion | leafmaple# | WA | 3700ms | 494744kb | C++20 | 1.4kb | 2024-09-29 16:26:32 | 2024-09-29 16:26:34 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 100000000000001921;
const int N = 2e6+10;
int f[N*5];
bool cmp (string a,string b )
{
return a.size() > b.size();
}
int a[N];
inline int mo(int x)
{
return x>= mod ? x -mod : x;
}
signed main (){
std::ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
f[1] = 1;
unordered_set<int> st;
// st.insert(1);
st.insert(0);
for(int i=2;i<=10000000+5;i++)
{ f[i] = mo(f[i-1] + f[i-2]) ;
//cout<<f[i]<<endl;
}
for(int i=2;i<=10000000+5;i++)
{
//cout<<f[i]<<' '<<st.count(f[i])
//(!st.count(f[i]));
st.insert(f[i]);
}
//
int n;
cin>>n;
vector<string> s(n);
for(int i=0;i<n;i++)
{
cin>>s[i];
}
sort(s.begin(),s.end(),cmp);
for(int i=0;i<n;i++)
{
int now = 0;
for(auto c:s[i])
{
now = (now*10 + (c-'0'))%mod;
}
a[i] = now ;
}
int ans = 0 ;
map<int,int> mp;
for(int i=0;i<n;i++)
{
if(s.size() > 1e3)
{
for(int j=i+1;j<n;j++)
{
if(st.count((a[i]+a[j])%mod))
ans ++;
}
}
else
{
ans += mp[a[i]];
//cout<<mp[1]<<endl;
for(int j= (s[i].size() -1 )*4;j<=10000+10;j++)
{
if(j == 2)
continue ;
mp[(f[j] - a[i] + mod )%mod] ++;
}
//cout<<i<<' '<<ans<<endl;
}
}
cout<<ans<<endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3700ms
memory: 493076kb
input:
6 50 8 8 5 72 354224848179261915070
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: -100
Wrong Answer
time: 3632ms
memory: 494744kb
input:
28 200878223506436882933619847964496455022155117513398820563747455993172799881403389571477889821109288771413214004090719097929400406252135763028179112130390003528046316900603668569910008417315162907579003880220844686222148696041857432602133894827753998572080650383305777912447151917272483538029469449...
output:
0
result:
wrong answer 1st numbers differ - expected: '27', found: '0'