![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
大水题
fibo_nacci
C/C coder
展开
-
hdoj 1157 Who's in the Middle
太水,STL排序可以过。G++判出来是15MS, 340K. 肯定有可以优化的,懒的找了。 #include #include #include using namespace std; int main() { int N, num; vector vec; //freopen("in.txt", "r", stdin); while(scanf("原创 2013-03-31 12:20:10 · 546 阅读 · 0 评论 -
pat basic level 1016
http://pat.zju.edu.cn/contests/pat-b-practise/1016 //Date : //Author : fibonacci // #include using namespace std; int main() { int DA, DB, A, B, cnt, PA = 0, PB = 0; //freopen("in.tx原创 2013-11-05 10:18:28 · 575 阅读 · 0 评论 -
hdoj 1048 The Hardest Problem Ever
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1048 水题,注意输入输出gets与puts的使用 #include #include using namespace std; char str[1000000]; int main() { while(gets(str) && strcmp(str, "ENDOFINPUT"))原创 2013-11-14 17:02:19 · 679 阅读 · 0 评论 -
hdoj 1017 A Mathematical Curiosity
题目:点击打开链接 直接暴力解了,注意用取余%来代替除法判断是否 (a^2+b^2 +m)/(ab) 是整除。 另外读清楚题目,注意输出格式,笔者三个PE了 78MS 228K 用时才78ms,数据应该不强的。 #include using namespace std; int main() { bool flag; int T, n, m, a,原创 2013-11-24 10:03:03 · 513 阅读 · 0 评论 -
hdoj 1032 The 3n + 1 problem
题目:题目链接 做过好几个3n+1的问题了,记得好像曾经有需要打表的,这题不用,直接暴力解,就是i可能会大于j,这一点比较坑。 不过一般来说题目的意思都会尽量表达的清楚的,当时WA了好几次也就想到了会不会是i大于j的情况,反正比较坑了。 #include using namespace std; int main() { int I, J, cnt, num, maxcnt原创 2013-11-23 19:42:58 · 517 阅读 · 0 评论 -
hdoj 2091 空心三角形
题目:空心三角形 比较简单,第一行和最后一行特殊输出,中间行用for就可以了。 要细心,注意题目的描述是两个图形间一个空行,所以最后一个图形就不要加空行了,笔者因此一个PE, hdoj上有的题目没描述清楚,最后一个case也要输出一个空行,没有空行还直接WA。所以多细致点。 用了个字符数组来接受图形字符,因此避免了用getchar()将空格过滤。 最开始用char ch; scanf("%原创 2013-11-21 15:37:31 · 766 阅读 · 0 评论 -
hdoj 1326 Box of Bricks
题目链接 只要求出大于均值或者小于均值的大小即可,注意可以使用求和函数accumulate,输出格式也要注意,水题。 #include #include using namespace std; int main() { int N, arr[51], avg; while(scanf("%d", &N) && N) { static int case原创 2013-11-20 09:52:54 · 581 阅读 · 0 评论 -
hdoj 1197 Specialized Four-Digit Numbers
http://acm.hdu.edu.cn/showproblem.php?pid=1197 挺简单的,弄清楚进制转换的本质就好了。本质就在代码里,看了discuss下有人用itoa转换成字符然后加,完全没必要了。 #include using namespace std; int main() { int a, b, c, d, desum, dusum, hesu原创 2013-11-19 14:19:06 · 598 阅读 · 0 评论 -
hdoj 1164 Eddy's research I
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1164 Problem Description Eddy's interest is very extensive, recently he is interested in prime number. Eddy discover the all number owned can be divided原创 2013-11-16 10:12:17 · 560 阅读 · 0 评论 -
hdoj 1196 Lowest Bit
最主要的是意识到被2整除的次数,有点像求一个数的2进制位是否只有一个1(2的次幂),相关问题联系起来就好。 //---- ---- Accepted 1196 0MS 200K 286 B G++ ---- #include using namespace std; int main() { int num, cnt; //freopen("in.txt", "r",原创 2013-04-01 16:30:00 · 472 阅读 · 0 评论 -
Leetcode Reverse Integer
地址:http://oj.leetcode.com/problems/reverse-integer/ 思路:简单吧,直接上代码了。 class Solution { public: int reverse(int x) { bool flag = true; if(x < 0) { flag = false;原创 2014-03-09 13:51:32 · 749 阅读 · 0 评论