QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#600510#9225. Fibonacci Fusionleafmaple#TL 3732ms494896kbC++201.4kb2024-09-29 17:02:302024-09-29 17:02:31

Judging History

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

  • [2024-09-29 17:02:31]
  • 评测
  • 测评结果:TL
  • 用时:3732ms
  • 内存:494896kb
  • [2024-09-29 17:02:30]
  • 提交

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]) ;
		st.insert(f[i]);
		//cout<<f[i]<<endl;
	}
//	for(int i=2;i<=10000000+5;i++)
//	{	
//		//cout<<f[i]<<' '<<st.count(f[i])
//		//(!st.count(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 ;
	unordered_map<int,int> mp;
	for(int i=0;i<n;i++)
	{
		if(s[i].size() > 1e3)
		{
			for(int j=i+1;j<n;j++)
			{
				if(st.count(mo(a[i]+a[j])))
					ans ++;
			}
		}
		else 
		{
			ans += mp[a[i]];
			//cout<<mp[1]<<endl;
			
			for(int j= (s[i].size() -1 )*4;j<=6000+10;j++)
			{
				if(j == 2)
					continue ;
					
				mp[mo(f[j] - a[i] + 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: 3732ms
memory: 491196kb

input:

6
50
8
8
5
72
354224848179261915070

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 0
Accepted
time: 3732ms
memory: 494896kb

input:

28
200878223506436882933619847964496455022155117513398820563747455993172799881403389571477889821109288771413214004090719097929400406252135763028179112130390003528046316900603668569910008417315162907579003880220844686222148696041857432602133894827753998572080650383305777912447151917272483538029469449...

output:

27

result:

ok 1 number(s): "27"

Test #3:

score: -100
Time Limit Exceeded

input:

5187
2640352926124261912741724778991366987330659389621881876017670644497364093930668042530271338851702874394631009332660937266680740235862107353443518003194307853104942996827176097428402408674756368623972812842571069642405111849826172879369776309763468485788964245903781380419155348915131587410703749...

output:


result: