6 条题解

  • 0
    @ 2024-3-11 16:34:03

    #include<bits/stdc++.h> using namespace std; int main(){ long long n,a=1,b=1,c; scanf("%lld",&n); if(na) { printf("YES"); exit(0); } while(1) { c=a+b; a=b; b=c; if(nc) { printf("YES"); exit(0); } if(c>n) { printf("NO"); exit(0); } } return 0; }

    • 0
      @ 2023-12-13 19:46:47

      这道题目比较简单,用一个死循环枚举斐波那契数就能解决,如果枚举到就退出,并输出“YES”,如果大于也退出, 并输出“NO”。 代码如下:

      #include <bits/stdc++.h>
      
      using namespace std;
      
      int main ()
      {
      	long long n, a = 1, b = 1, c;
      	scanf ("%lld", &n);
      	if (n == a)
      	{
      		printf ("YES");
      		exit (0);
      	}
      	while (1)
      	{
      		c = a + b;
      		a = b;
      		b = c;
      		if (n == c)
      		{
      			printf ("YES");
      			exit (0);
      		}
      		if (c > n)
      		{
      			printf ("NO");
      			exit (0);
      		}
      	}
      	return 0;
      }
      
      
      • 0
        @ 2023-10-19 19:04:14
        #include<bits/stdc++.h>
        using namespace std;
        long long a=1,b=1,c=2,n;
        int main(){
        	cin>>n;
        	while(n>c){
        		a=b;
        		b=c;
        		c=a+b;
        	}if(n==c)cout<<"YES";
        	else cout<<"NO";
        }
        
        • 0
          @ 2023-10-12 21:06:13

          #include<bits/stdc++.h> using namespace std; int s,h,a[100010]={0,1}; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; for(int i=2;a[i-1]<n;i++) { a[i]=a[i-1]+a[i-2]; if(a[i]==n) { cout<<"YES"; return 0; } } cout<<"NO"; return 0; }

          • 0
            @ 2023-8-28 9:21:32
            #include<bits/stdc++.h>
            using namespace std;
            int s,h,a[100010]={0,1};
            int main()
            {
            	ios::sync_with_stdio(0);
            	cin.tie(0);
            	cout.tie(0);
            	int n;
            	cin>>n;
            	for(int i=2;a[i-1]<n;i++)
            	{
            		a[i]=a[i-1]+a[i-2];
            		if(a[i]==n)
            		{
            			cout<<"YES";
            			return 0;
            		}
            	}
            	cout<<"NO";
            	return 0;
            }
            
            • 0
              @ 2023-7-20 14:59:09

              #include<bits/stdc++.h> using namespace std; int n,a,b,c; int main(){ cin>>n; a=1; b=1; while(1){ c=a+b; a=b; b=c; if(c==n){ cout<<"YES"; return 0; } if(c>n){ cout<<"NO"; return 0; } } return 0; }

              • 1

              信息

              ID
              9
              时间
              1000ms
              内存
              256MiB
              难度
              3
              标签
              (无)
              递交数
              88
              已通过
              46
              上传者