HDU 2914 Triangle (Fibnacci 数)
题意:给你一个长度为 n 的木棒,求至少拿掉几根使得剩余的木棒构成不了三角形。
析:为了保证不形成三角形,所以保证两边之和等于最大边是最优,这不就是Fibnacci 数么,由于 n 很小,if-else 就好。
代码如下:
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
//#include <tr1/unordered_map>
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std;
//using namespace std :: tr1; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const LL LNF = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1e3 + 5;
const LL mod = 10000000000007;
const int N = 1e6 + 5;
const int dr[] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1};
const char *Hex[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
inline LL gcd(LL a, LL b){ return b == 0 ? a : gcd(b, a%b); }
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int Min(int a, int b){ return a < b ? a : b; }
inline int Max(int a, int b){ return a > b ? a : b; }
inline LL Min(LL a, LL b){ return a < b ? a : b; }
inline LL Max(LL a, LL b){ return a > b ? a : b; }
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
} int main(){
int T; cin >> T;
for(int kase = 1; kase <= T; ++kase){
cin >> n;
printf("Case #%d: ", kase);
if(n < 4) printf("0");
else if(n < 6) printf("1");
else if(n < 8) printf("%d", n-4);
else if(n < 13) printf("%d", n-5);
else printf("%d", n-6);
printf("\n");
}
return 0;
}
HDU 2914 Triangle (Fibnacci 数)的更多相关文章
- [Usaco2010 OPen]Triangle Counting 数三角形
[Usaco2010 OPen]Triangle Counting 数三角形 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 394 Solved: 1 ...
- bzoj 1914: [Usaco2010 OPen]Triangle Counting 数三角形 容斥
1914: [Usaco2010 OPen]Triangle Counting 数三角形 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 272 Sol ...
- 网络流(最大流) HDU 1565 方格取数(1) HDU 1569 方格取数(2)
HDU 1565 方格取数(1) 给你一个n*n的格子的棋盘,每个格子里面有一个非负数.从中取出若干个数,使得任意的两个数所在的格子没有公共边,就是说所取的数所在的2个格子不能相邻,并且取出的数的 ...
- HDU 1565 - 方格取数(1) - [状压DP][网络流 - 最大点权独立集和最小点权覆盖集]
题目链接:https://cn.vjudge.net/problem/HDU-1565 Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32 ...
- bzoj1914 [Usaco2010 OPen]Triangle Counting 数三角形 计算机和
[Usaco2010 OPen]Triangle Counting 数三角形 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 526 Solved: 2 ...
- HDU 5914 Triangle(打表——斐波那契数的应用)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5914 Problem Description Mr. Frog has n sticks, whos ...
- HDU 1394Minimum Inversion Number 数状数组 逆序对数量和
Minimum Inversion Number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java ...
- HDU 5914 Triangle 数学找规律
Triangle 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5914 Description Mr. Frog has n sticks, who ...
- hdu 4324 Triangle LOVE
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4324 Triangle LOVE Description Recently, scientists f ...
随机推荐
- 【POJ2406】Power Strings(KMP,后缀数组)
题意: n<=1000000,cas较大 思路:这是一道论文题 后缀数组已弃疗,强行需要DC3构造,懒得(不会)写 ..]of longint; n,m,i,j,len,ans,st:longi ...
- T1503 愚蠢的宠物 codevs
http://codevs.cn/problem/1503/ 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description 大家都知道,sh ...
- ArcGIS Engine中的Symbols详解
转自原文ArcGIS Engine中的Symbols详解 本文由本人翻译ESRI官方帮助文档.尊重劳动成果,转载请注明来源. Symbols ArcObjects用了三种类型的Symbol(符号样式) ...
- Oracle冷备和热备脚本
Oracle冷备和热备脚本 冷备脚本: set feedback off set heading off set verify off set trimspool off set echo off ...
- 【求建议】毕业之声——信院IT类毕业学子经验分享交流会
一:缘由 在和非常多学子交流,及上课的经历中,发现一个非常普遍的现象:部分大一学生即失去了对学习.对专业的兴趣.有人在迷茫之后奋起直追.从而珍惜利用不多的大学时光努力提高自己.有人在迷茫中沉沦,沉迷于 ...
- ZOJ 2706 Thermal Death of the Universe (线段树)
题目链接:ZOJ 2706 Thermal Death of the Universe (线段树) 题意:n个数.m个操作. 每一个操作(a,b)表示(a,b)全部值更新为这个区间的平均数:1.当前的 ...
- 【Mongodb教程 第十五课 】MongoDB 限制记录
Limit() 方法 要限制 MongoDB 中的记录,需要使用 limit() 方法. limit() 方法接受一个数字型的参数,这是要显示的文档数. 语法: limit() 方法的基本语法如下 & ...
- 怎样用Google APIs和Google的应用系统进行集成(8)----怎样把Google Blogger(博客)的JSON Schema转换成XML的Schema(XSD)?
在Google RESTFul API中,Google Blogger API(Google博客API)应该和我们的生活离得近期:由于差点儿非常多人每天都在看博客,都在写博客,都听说过博客.在前面的G ...
- Django框架之路由
1,路由系统就是url系统,整个url系统就是请求进入Django项目的入口,每一个请求的种类由url分析完毕并再去返回相应的响应,它的本质是url与要为该url调用的视图函数之间的映射关系表(当项目 ...
- my.cnf配置详解[转载]
先粘贴一份mac下的mysql5.6.22的配置文件 # Example MySQL config file for medium systems. # # This is for a system ...