QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#668221#9225. Fibonacci Fusion11d10xyRE 131ms253844kbC++141.1kb2024-10-23 12:40:542024-10-23 12:40:54

Judging History

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

  • [2024-10-23 12:40:54]
  • 评测
  • 测评结果:RE
  • 用时:131ms
  • 内存:253844kb
  • [2024-10-23 12:40:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using i64=long long;
constexpr double W=4.784971965;
constexpr i64 mod[3]{998244353,998244853,1000000007};
array<i64,3>fib[10000010];
char buf[2000010];
string str[100010];
map<array<i64,3>,int>cnt;
int main(){
   fib[1]={1,1,1};
   for(int i=2;i<=10000000;i++){
      for(int t:{0,1,2})fib[i][t]=(fib[i-1][t]+fib[i-2][t])%mod[t];
   }
   int n;scanf("%d",&n);
   i64 ans=0;
   for(int i=1;i<=n;i++)scanf("%s",buf),str[i].assign(buf);
   sort(str+1,str+n+1,[](const string&x,const string&y){
      if(x.length()!=y.length())return x.length()<y.length();
      return lexicographical_compare(rbegin(x),rend(x),rbegin(y),rend(y));
   });
   for(int i=1;i<=n;i++){
      int m=str[i].length(),L=max(2,(int)(W*(m-1)-2)),R=W*(m+1)+3;
      array<i64,3>a{};
      for(char c:str[i]){
         for(int t:{0,1,2})a[t]=(a[t]*10+c-'0')%mod[t];
      }
      for(int k=L;k<=R;k++){
         array<i64,3>b{};
         for(int t:{0,1,2})b[t]=(fib[k][t]+mod[t]-a[t])%mod[t];
         ans+=cnt[b];
      }cnt[a]++;
   }
   printf("%lld",ans);
   return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 48ms
memory: 243316kb

input:

6
50
8
8
5
72
354224848179261915070

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 0
Accepted
time: 91ms
memory: 247796kb

input:

28
200878223506436882933619847964496455022155117513398820563747455993172799881403389571477889821109288771413214004090719097929400406252135763028179112130390003528046316900603668569910008417315162907579003880220844686222148696041857432602133894827753998572080650383305777912447151917272483538029469449...

output:

27

result:

ok 1 number(s): "27"

Test #3:

score: 0
Accepted
time: 131ms
memory: 253844kb

input:

5187
2640352926124261912741724778991366987330659389621881876017670644497364093930668042530271338851702874394631009332660937266680740235862107353443518003194307853104942996827176097428402408674756368623972812842571069642405111849826172879369776309763468485788964245903781380419155348915131587410703749...

output:

6073

result:

ok 1 number(s): "6073"

Test #4:

score: -100
Runtime Error

input:

200000
2
2
2
2
1
2
1
1
2
2
1
1
1
2
2
1
1
2
1
1
2
2
1
2
2
2
1
1
1
1
2
2
1
2
1
2
1
1
2
2
1
1
1
2
1
1
2
1
2
2
2
2
1
2
2
1
1
1
2
1
1
1
1
1
2
1
2
2
1
1
1
2
2
2
1
1
2
1
1
2
1
2
1
1
1
2
2
2
1
1
1
1
2
1
2
1
1
2
2
1
1
2
1
1
2
1
2
2
1
2
1
2
2
1
1
2
1
1
1
2
2
2
1
2
2
1
1
2
2
2
2
1
2
1
1
2
1
2
2
1
1
1
1
2
2
2
2...

output:


result: