无限序列(有误)

This commit is contained in:
James 2020-05-03 18:35:08 +08:00
parent c6aac5f996
commit 3915986673
11 changed files with 1420 additions and 0 deletions

View File

@ -0,0 +1,3 @@
# 标题
* 内容

View File

@ -0,0 +1 @@
#

Binary file not shown.

48
2864_wuxianxulie/main.cpp Normal file
View File

@ -0,0 +1,48 @@
#include <iostream>
#include<cstdio>
using namespace std;
long long dg(long long n)
{
cout<<n<<":";
if(n<=2){
return 1;
}
if(n==3){
return 2;
}
long long yi1 = 1, yi2 = 1;
long long lin1 = 1, lin2 = 0;
long long ans = 1, now = 2;
while(now<n){
printf("%dÖÐÓÐ%d¸öÒ»;",now,ans);
printf("%d %d ",yi2,yi1);
printf("%d %d\n",lin2,lin1);
// printf("%dÖÐÓÐ%d¸öÒ»;",now,ans);
// printf("%d %d ",yi2,yi1);
// printf("%d %d ",lin2,lin1);
long long u=yi1+yi2;
yi2=yi1;
yi1=u;
long long u0=lin1+lin2;
lin2=lin1;
lin1=u0;
ans+=yi1;
now+=yi1+lin1;
if(now==n){
return ans;
}
if(now>n){
return ans-yi1+dg(n-(now-yi1-lin1));
}
}
}
int main()
{
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
long long yi, er;
cin >> yi >> er;
cout <<endl<< dg(er) - dg(yi-1);
}
}

BIN
2864_wuxianxulie/main.exe Normal file

Binary file not shown.

View File

@ -0,0 +1,30 @@
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
unsigned long long t,a[101],x,y;
unsigned long long find(unsigned long long now)//求区间1和now之间有多少个1
{
unsigned long long ans=0,j;//初始化
while (now)//还可以拆分
{
j=1;
while (a[j+2]<=now) j++;//寻找可以减的
ans+=a[j];//加上一的个数
now-=a[j+1];//减(拆分)
}
return ans;
}
int main()
{
scanf("%llu",&t);//读入
a[1]=1; a[2]=1;//初始化
for (int i=3;i<=100;i++)
a[i]=a[i-1]+a[i-2];//斐波那契
for (unsigned long long i=1;i<=t;i++)
{
scanf("%llu%llu",&x,&y);//读入
printf("%llu\n",find(y)-find(x-1));//利用前缀和求出答案,然后输出
}
return 0;
}

BIN
2864_wuxianxulie/other.exe Normal file

Binary file not shown.

View File

@ -0,0 +1,11 @@
10
6 13
21 81
25 77
9 37
29 89
48 97
41 65
65 85
42 98
17 73

View File

@ -0,0 +1,11 @@
10
17 165
281 857
481 634
106 209
409 493
162 945
169 692
761 769
345 769
291 953

View File

@ -0,0 +1,11 @@
10
817 1985
3697 7649
4033 6049
1089 7969
2726 7266
1425 7954
243 5137
1233 1985
1889 9617
1969 6673

File diff suppressed because it is too large Load Diff