摘要: int gcd (int x, int y)//最大公约数 { return y == 0 ? x : gcd( y , x % y ); } int lcm(int x, int y)//最小公倍数 { return x*y/gcd(x,y); } 阅读全文
posted @ 2016-02-24 15:57 一根咸鱼干 阅读(91) 评论(0) 推荐(0) 编辑
摘要: Description Background Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two different gende 阅读全文
posted @ 2016-02-24 15:22 一根咸鱼干 阅读(86) 评论(0) 推荐(0) 编辑
摘要: Description Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. 阅读全文
posted @ 2016-02-24 15:18 一根咸鱼干 阅读(72) 评论(0) 推荐(0) 编辑
摘要: Description Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 阅读全文
posted @ 2016-02-22 21:01 一根咸鱼干 阅读(78) 评论(0) 推荐(0) 编辑
摘要: Description Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <= 10 阅读全文
posted @ 2016-02-22 19:09 一根咸鱼干 阅读(134) 评论(0) 推荐(0) 编辑
摘要: DFS主要在于参数的改变; 样例输入: n=4 //给定n个数字 a={1,2,4,7} //输入n个数据 k=15 //目标数字 样例输出: No 题意: 给定的数字在不重复使用的前提下能否达到目标,能输出Yes,否输出No#include<algorithm> #include<iostream 阅读全文
posted @ 2016-02-22 19:07 一根咸鱼干 阅读(236) 评论(0) 推荐(0) 编辑
摘要: 每瓶啤酒2元,2个空酒瓶或4个瓶盖可换1瓶啤酒。10元最多可喝多少瓶啤酒? #include<algorithm> #include<iostream> using namespace std; int dfs(int p, int g, int ans) { if(p < 2 && g < 4) 阅读全文
posted @ 2016-02-22 18:51 一根咸鱼干 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 位运算加速技巧1. 如果乘上一个2的倍数数值,可以改用左移运算(Left Shift) 加速 300% x = x * 2; x = x * 64; //改为: x = x << 1; // 2 = 21 x = x << 6; // 64 = 26 2. 如果除上一个 2 的倍数数值,可以改用右移 阅读全文
posted @ 2016-02-22 15:14 一根咸鱼干 阅读(422) 评论(0) 推荐(0) 编辑
摘要: Description The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangula 阅读全文
posted @ 2016-02-22 14:58 一根咸鱼干 阅读(102) 评论(0) 推荐(0) 编辑
摘要: Description Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,00 阅读全文
posted @ 2016-02-22 14:55 一根咸鱼干 阅读(93) 评论(0) 推荐(0) 编辑