QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#705404#9225. Fibonacci FusionjimmyywangTL 128ms176504kbC++141.4kb2024-11-02 23:20:102024-11-02 23:20:10

Judging History

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

  • [2024-11-02 23:20:10]
  • 评测
  • 测评结果:TL
  • 用时:128ms
  • 内存:176504kb
  • [2024-11-02 23:20:10]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
// #define mp make_pair
#define pb push_back
#define f(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
ll rd(){
    ll x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
#define d rd()

ll n;
const ll mod[2]={1000000007,998244353};
map<pair<ll,ll>,ll>mp;
ll fib[20000010][2];
// ll a[200010][2];
char c[2000010];
struct node{ll x,y,o;}a[200010];
bool cmp(node a,node b){return a.o<b.o;}
ll res;
const double lgphi=1.0/log10((1+sqrt(5))/2);
int main(){
    n=d;fib[1][0]=fib[1][1]=1;
    f(i,2,10000000)fib[i][0]=(fib[i-1][0]+fib[i-2][0])%mod[0],fib[i][1]=(fib[i-1][1]+fib[i-2][1])%mod[1];
    f(i,1,n){
        scanf("%s",c+1);
        ll x=0,y=0;ll t=strlen(c+1);
        double k=0,o=0;
        f(j,1,t){
            if(j<=20)k=k*10+c[j]-'0';else o++;
            x=(x*10+c[j]-'0')%mod[0];
            y=(y*10+c[j]-'0')%mod[1];
        }ll len=(1.0*(log10(sqrt(5))+log10(k)+o)*lgphi);
        a[i]={x,y,len};
    }
    sort(a+1,a+n+1,cmp);
    f(i,1,n){
        for(int j=max(0ll,a[i].o-20);j<=min(a[i].o+20,10000000ll);j++){
            res+=mp[{(fib[j][0]-a[i].x+mod[0])%mod[0],(fib[j][1]-a[i].y+mod[1])%mod[1]}];
        }mp[{a[i].x,a[i].y}]++;
    }
    cout<<res<<endl;
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 59ms
memory: 163988kb

input:

6
50
8
8
5
72
354224848179261915070

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 0
Accepted
time: 67ms
memory: 162460kb

input:

28
200878223506436882933619847964496455022155117513398820563747455993172799881403389571477889821109288771413214004090719097929400406252135763028179112130390003528046316900603668569910008417315162907579003880220844686222148696041857432602133894827753998572080650383305777912447151917272483538029469449...

output:

27

result:

ok 1 number(s): "27"

Test #3:

score: 0
Accepted
time: 128ms
memory: 176504kb

input:

5187
2640352926124261912741724778991366987330659389621881876017670644497364093930668042530271338851702874394631009332660937266680740235862107353443518003194307853104942996827176097428402408674756368623972812842571069642405111849826172879369776309763468485788964245903781380419155348915131587410703749...

output:

6073

result:

ok 1 number(s): "6073"

Test #4:

score: 0
Accepted
time: 85ms
memory: 167600kb

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:

15003749259

result:

ok 1 number(s): "15003749259"

Test #5:

score: -100
Time Limit Exceeded

input:

200000
944176313232170622314
2590599414036674999101
753315073608896000424
9299685298577430049245
9361800333778142620806
8988699166328904060999
9606920674025578304023
4203331868598952026136
5183047027116137697788
3968714342776915029801
8130984095583566992354
3206443643596048048798
6248561214283254355...

output:


result: