QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#600435#9225. Fibonacci Fusionleafmaple#TL 3667ms489024kbC++201.2kb2024-09-29 16:33:352024-09-29 16:33:35

Judging History

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

  • [2024-09-29 16:33:35]
  • 评测
  • 测评结果:TL
  • 用时:3667ms
  • 内存:489024kb
  • [2024-09-29 16:33:35]
  • 提交

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])
		assert(!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++)
	{
		ans += mp[a[i]];
		//cout<<mp[1]<<endl;
		for(int j= (s[i].size() -1 )*4;j<=s[i].size()*5+100;j++)
		{
			if(j == 2)
				continue ;
				
			mp[(f[j] - a[i] + mod )%mod] ++;
		}

	}
	cout<<ans<<endl;
	
	
	
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3667ms
memory: 489024kb

input:

6
50
8
8
5
72
354224848179261915070

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: -100
Time Limit Exceeded

input:

28
200878223506436882933619847964496455022155117513398820563747455993172799881403389571477889821109288771413214004090719097929400406252135763028179112130390003528046316900603668569910008417315162907579003880220844686222148696041857432602133894827753998572080650383305777912447151917272483538029469449...

output:


result: