# 牛客OI赛制测试赛1 题解

$fib[i+1]fib[i-1]-fib[i]^2=(-1)^i$，其中$(i>1,i \in N_+ )$

$fib[1]=fib[2]=1,fib[3]=2$
$fib[3]*fib[1]-fib[2]^2=2*1-1^2=(-1)^2$

$fib[n+2]fib[n]-fib[n+1]^2$
$=(fib[n+1]+fib[n])*fib[n]-(fib[n]+fib[n-1])^2$
$=fib[n]^2+fib[n]fib[n+1]-fib[n]^2-fib[n-1]^2-2fib[n]fib[n-1]$
$=fib[n]^2+fib[n](fib[n+1]-fib[n])-fib[n-1]^2-2fib[n]fib[n-1]$
$=fib[n]^2+fib[n]fib[n-1]-2fib[n]fib[n-1]-fib[n-1]^2$
$=fib[n]^2-fib[n]fib[n-1]-fib[n-1]^2$
$=fib[n]^2-fib[n-1](fib[n]+fib[n-1])$
$=fib[n]^2-fib[n-1]fib[n+1]$
$=(-1)(fib[n]^2-fib[n-1]fib[n+1])$
$=(-1)(-1)^n$
$=(-1)^{n+1}$

$code:$
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char n[1000010];int l;int num;
int main()
{
cin>>n;
int l=strlen(n);
num=n[l-1]-'0';
printf("%d",num%2==0?1:-1);
return 0;
}

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
long long f[100001];
int main()
{
f[1]=f[2]=1;
for(int i=2;i<=30;i++)
f[i+1]=f[i]+f[i-1],
printf("%lld ",f[i-1]*f[i+1]-f[i]*f[i]);
return 0;
}

#include<cstdio>
#include<iostream>
using namespace std;
int a,b,c;
int main(){long long l=1,r=int(1e9)<<1:cin》a>>b;while(r-l>1){c=(l+r)>>1;if(c-b<a)l=c;else if(c-b>a)r=c;else return printf("%d\n",c);
}     if(l!=r)return printf("%d\n",r);
}

$qwq$

#include<cstdio>
#include<algorithm>
using namespace std;
int a[400005];
int d[400005];
int main()
{
int n;
scanf("%d",&n);
for (int i=1;i<=n;i++) scanf("%d",&a[i]);
if (n==0)
{
printf("0\n");
return 0;
}
d[1]=a[1];
int len=1;
for (int i=2;i<=n;i++)
{
if (a[i]>=d[len]) d[++len]=a[i];
else
{
int j=upper_bound(d+1,d+len+1,a[i])-d;
d[j]=a[i];
}
}
printf("%d\n",len);
return 0;
}

posted @ 2018-09-03 21:04  米罗偕涯  阅读(695)  评论(3编辑  收藏  举报