• 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, 3n 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 to steal some sticks! Output the minimal number of sticks he should steal so that Mr. Frog cannot form a triangle with
    any three of the remaining sticks.
     
    Input
    The first line contains only one integer T (T20), which indicates the number of test cases. 

    For each test case, there is only one line describing the given integer n (1n20).
     
    Output
    For each test case, output one line “Case #x: y”, where x is the case number (starting from 1), y is the minimal number of sticks Wallice should steal.
     
    Sample Input
    3 4 5 6
     
    Sample Output
    Case #1: 1 Case #2: 1 Case #3: 2

    题目链接:

      http://acm.hdu.edu.cn/showproblem.php?pid=5914

    题目大意:

      给你1~N(N<=20)长度的木棒,求至少拿掉几根使得剩余的木棒构成不了三角形。

    题目思路:

      【模拟】

      画画前几个就可以得出,剩下的木棒是斐波那契数列1,2,3,5,8,13。N只有20,打表。

     1 //
     2 //by coolxxx
     3 //#include<bits/stdc++.h>
     4 #include<iostream>
     5 #include<algorithm>
     6 #include<string>
     7 #include<iomanip>
     8 #include<map>
     9 #include<stack>
    10 #include<queue>
    11 #include<set>
    12 #include<bitset>
    13 #include<memory.h>
    14 #include<time.h>
    15 #include<stdio.h>
    16 #include<stdlib.h>
    17 #include<string.h>
    18 //#include<stdbool.h>
    19 #include<math.h>
    20 #define min(a,b) ((a)<(b)?(a):(b))
    21 #define max(a,b) ((a)>(b)?(a):(b))
    22 #define abs(a) ((a)>0?(a):(-(a)))
    23 #define lowbit(a) (a&(-a))
    24 #define sqr(a) ((a)*(a))
    25 #define swap(a,b) ((a)^=(b),(b)^=(a),(a)^=(b))
    26 #define mem(a,b) memset(a,b,sizeof(a))
    27 #define eps (1e-10)
    28 #define J 10000
    29 #define mod 1000000007
    30 #define MAX 0x7f7f7f7f
    31 #define PI 3.14159265358979323
    32 #pragma comment(linker,"/STACK:1024000000,1024000000")
    33 #define N 104
    34 using namespace std;
    35 typedef long long LL;
    36 double anss;
    37 LL aans,sum;
    38 int cas,cass;
    39 int n,m,lll,ans;
    40 int a[]={0,0,0,0,1,1,2,3,3,4,5,6,7,7,8,9,10,11,12,13,14};
    41 int main()
    42 {
    43     #ifndef ONLINE_JUDGEW
    44 //    freopen("1.txt","r",stdin);
    45 //    freopen("2.txt","w",stdout);
    46     #endif
    47     int i,j,k;
    48 //    init();
    49 //    for(scanf("%d",&cass);cass;cass--)
    50     for(scanf("%d",&cas),cass=1;cass<=cas;cass++)
    51 //    while(~scanf("%s",s))
    52 //    while(~scanf("%d",&n))
    53     {
    54         scanf("%d",&n);
    55         printf("Case #%d: ",cass);
    56         printf("%d
    ",a[n]);
    57     }
    58     return 0;
    59 }
    60 /*
    61 //
    62 
    63 //
    64 */
    View Code
  • 相关阅读:
    Java Web(三) 会话机制,Cookie和Session详解(转载)
    如何转载别人的文章
    C#操作Word的+ CKEditor 輸出成Word文件(包含圖案上傳)
    vs2013 命名空间“Microsoft.Office”中不存在类型或命名空间名称“Interop”。是否缺少程序集引用?
    CKEditor与CKFinder学习--自定义界面及按钮事件捕获
    JS获取CkEditor在线编辑的内容
    <%#Eval() %>的常用方法
    ASP.NET 中 ContentType 类型
    富文本编辑器 CKeditor 配置使用+上传图片
    VS2013 蛋疼的“AJAX Control Toolkit”安装过程
  • 原文地址:https://www.cnblogs.com/Coolxxx/p/5930395.html
Copyright © 2020-2023  润新知