zoukankan      html  css  js  c++  java
  • HDU 5167

    范围 内的斐波那契的数不多,求出范围内的数,再暴力枚举即可。

    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <cmath>
    #include <cstring>
    using namespace std;
    #define  N 1000000000
    __int64 foci[200];
    int fc=0,cnt;
    __int64 tmp[50];
    
    void init(){
    	foci[0]=0; foci[1]=1;
    	fc=1;
    	for(fc=2;foci[fc-1]<=N;fc++){
    		foci[fc]=foci[fc-1]+foci[fc-2];
    	//	cout<<foci[fc]<<endl;
    	}
    	fc=fc-1;
    }
    
    bool dfs(__int64 n,int pos){
    	if(n==1LL) return true;
    	for(int i=pos;i<=cnt;i++){
    		if(n%tmp[i]==0&&dfs(n/tmp[i],i))
    		return true;
    	}
    	return false;
    }
    
    int main(){
    	init();
    	int T,i;
    	__int64 n;
    	scanf("%d",&T);
    	while(T--){
    		scanf("%I64d",&n);
    		if(n==0||n==1LL){
    			printf("Yes
    ");
    			continue;
    		}
    		i=3; cnt=0;
    		for(i;i<=fc;i++){
    			if(n%foci[i]==0)
    			tmp[++cnt]=foci[i];
    		}
    		bool flag=dfs(n,1);
    		if(flag)
    		printf("Yes
    ");
    		else printf("No
    ");
    	}
    	return 0;
    }
    

      

  • 相关阅读:
    Daily Scrum (2015/10/28)
    Dailu Scrum (2015/10/27)
    wenbao与cmd
    wenbao与IIS
    wenbao与模板
    wenbao与git
    wenbao与vscode
    wenbao与矩阵
    wenbao与面试题
    wenbao 与将linux系统(kali)装入U盘
  • 原文地址:https://www.cnblogs.com/jie-dcai/p/4287716.html
Copyright © 2011-2022 走看看