CCPC2016长春D (hdu 5914 Triangle)

water,给一个数n,问从1...n的数字里最少删去多少数字让剩下的数字必不可能组成三角形。

保留的数字必定是1、2、3、5、8、13、21.....这样的数字。

//#define test
#include<bits/stdc++.h>
using namespace std;
const int Nmax=1e6+7;
typedef long long ll;
int _,n;
int f[10],cas=1;
int main()
{
    #ifdef test
    #endif
   // freopen("d.in","r",stdin);
    scanf("%d",&_);
    f[1]=1,f[2]=2,f[3]=3,f[4]=5,f[5]=8,f[6]=13,f[7]=21;
    while(_--){
        int ans=0;
        printf("Case #%d: ",cas++);
        scanf("%d",&n);
        if(n==1||n==2){
            printf("0\n");
            continue;
        }
        for(int i=1;i<=7;i++){
            if(n>=f[i]) ans++;
            else break;
        }
        printf("%d\n",n-ans);
    }
    return 0;
}

原文地址:https://www.cnblogs.com/LMissher/p/9673990.html

时间: 2024-10-12 03:55:41

CCPC2016长春D (hdu 5914 Triangle)的相关文章

HDU 5914 Triangle 【构造】 (2016中国大学生程序设计竞赛(长春))

Triangle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 0    Accepted Submission(s): 0 Problem Description Mr. Frog has n sticks, whose lengths are 1,2, 3?n respectively. Wallice is a bad man,

HDU 5914 Triangle(打表——斐波那契数的应用)

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5914 Problem Description Mr. Frog has n sticks, whose lengths are 1,2, 3?n respectively. Wallice is a bad man, so he does not want Mr. Frog to form a triangle with three of the sticks here. He decides t

hdu 5914 Triangle

题意:1 2 ....n,这些边中最少抽出多少条边,使得剩下的边无法组成三角形 分析:开始的时候有点zz,IDA*跑了一发,2^(n-2)*n^3,跑了5min出了17,剩下的怎么都出不来了,然后YY了一下n和ans[n]之间的差,就过了,后来想了一下使得剩下的边都不能组成三角形,只要剩下的都是Fibonacci序列中的数就行了,想想IDA*简直就s是zz啊 #include<bits/stdc++.h> using namespace std; int dp[25]; int main(){

CCPC2016长春F (hdu 5916 Harmonic Value Description)

构造一个n个数字的排列,使其作为 sigma( gcd( a[i] , a[i+1] ) ) 中第k小的排列. 因为题目给的 k*2 <= n ,所以可以知道只会询问最小到第 n/2 小,易得最多移动一个数字即可得到答案. 假设原始排列为1 2 3 ... n,如果询问最小直接输出排列,否则询问x且x是偶数就把x移动到2*n与2*n-1之间. 如果x是奇数就将x与 2*n-1或者2*n+1交换.因为有可能2*n-1和2*n+1与x-1或者x+1不互质. //#define test #inclu

CCPC2016长春B (hdu 5912 Fraction)

water //#define test #include<bits/stdc++.h> using namespace std; const int Nmax=1e6+7; typedef long long ll; struct LL { ll a,b; LL(){ } LL(ll aa,ll bb){ a=aa,b=bb; ll g=__gcd(a,b); a/=g; b/=g; } friend LL operator + (const LL &a,const LL &

HDU 4324 Triangle LOVE (拓扑排序)

Triangle LOVE Problem Description Recently, scientists find that there is love between any of two people. For example, between A and B, if A don't love B, then B must love A, vice versa. And there is no possibility that two people love each other, wh

HDU 4324:Triangle LOVE( 拓扑排序 )

Triangle LOVE Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 2271    Accepted Submission(s): 946 Problem Description Recently, scientists find that there is love between any of two people. For

hdu 4324 Triangle LOVE(拓扑排序)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4324 Triangle LOVE Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 3858    Accepted Submission(s): 1516 Problem Description Recently, scientists f

HDU 4324 Triangle LOVE(拓扑排序判环)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4324 题目: Problem Description Recently, scientists find that there is love between any of two people. For example, between A and B, if A don’t love B, then B must love A, vice versa. And there is no possi