
POJ
文章平均质量分 56
yzl_rex
这个作者很懒,什么都没留下…
展开
-
poj 1003 Hangover
#include "iostream"using namespace std;int main(){ double len, sum; int i; while (cin >> len && len != 0.00) { sum = 0; for (i = 2; ; i++) { sum += 1 * 1.0/i; if (sum > len) br原创 2012-04-27 10:57:52 · 462 阅读 · 1 评论 -
poj 1611 The Suspects
//首次接触并查集,虽然是最基本的题目,但是不是很会做,//所以就看明白了并查集(看算法导论)和别人的代码之后,再自己写出来的!#include "iostream"using namespace std;const int maxsize = 30010;int pa[maxsize];//每一个集合中元素的父节点int ranks[maxsize];//每一个集合中元素的秩in原创 2012-04-27 10:59:14 · 381 阅读 · 0 评论 -
poj 1004 Financial Management
#include "iostream"//输入12个数,然后求其平均数!#include "cstdio"using namespace std;int main(){ double num, ans, sum = 0; for (int i = 0; i < 12; i++) { cin >> num; sum += num; } ans = sum / 12;原创 2012-04-26 23:14:34 · 490 阅读 · 0 评论 -
poj 2524 Ubiquitous Religions
//这题是我接触并查集的第二题,好顺利AC了!//题目给出几个数据对,在同一个数据对中的人的信仰是相同的,需要你求出在给定的人数中,有几种信仰!//将有相同信仰的人组成一颗树,然后统计数的棵树,再加上还有统计的人数,就可以得出了答案!#include "iostream"#include "memory.h"#include "set"using namespace std;con原创 2012-04-27 19:17:04 · 526 阅读 · 0 评论 -
poj 1835 宇航员
//这一模拟题,我之前有接触过,我记得刚开始不会做,然后看了别人的代码,然后再自己写一遍出来,现在再来做的时候,发现自己原来还不会做,所以这次我没有看别人的代码,完全靠自己//的思考解决了这一题!事实证明:没有经过自己思考的东西是记不住和学不会的,以后需要勤动动脑才可以!谨记!//最开始我思考这一模拟题的时候,卡住我思路的是:一直想将宇航员的状态在数组中一一表示出来,然后就可以轻松的求出他的坐原创 2012-04-30 12:23:40 · 1407 阅读 · 1 评论 -
poj 3299 Humidex
//题目很简单:给出两个数,求第三个数! //ln函数在c++中的函数原型是log(),exp()函数是以e为底,x为幂的函数!谨记! #include "iostream"#include "string"#include "cmath"#include "stdio.h"using namespace std;int main(){ string str1, str2原创 2012-05-01 21:31:35 · 429 阅读 · 0 评论 -
poj1676 What time is it?
//这一题真是耗尽了脑汁也找不出WA在哪!?(好打击人的一题) //我的思路是:将输入的LED时钟还原为数字,然后再一一进行匹配,过程可以进行一些剪枝操作(例如第一个数字不可以大于2,第三个数字不可以大于6)//得出了第一个时钟的正确时间,然后再减去15分钟,得出第二个时钟的时间,再在第二个时钟的字符串中寻找是否存在着这些数字,如果存在,匹配数就加1//到最后如果匹配数大于1又或者为0,就输原创 2012-05-01 17:12:50 · 1192 阅读 · 0 评论 -
poj 2159 Ancient Cipher
/*完全没有看懂题意,题目需要求的是:(粘贴别人的题意)这道题如果没看懂题意,绝对不是水题,能愁死你,而如果看懂了的话,的确稍微有点小水。关键是对代替加密和置换加密的理解,题目中给出的例子容易误导你进入误区: 代替加密是按照一定规律来的。所以你会很容易的想到先排序,找两个字符串的差距,如果一样就YES了。。其实,代替加密没有“规律”!A可以对应任意的26个字母。不知道说明白了没有所以 是否原创 2012-05-01 23:49:05 · 427 阅读 · 0 评论 -
poj 2739 Sum of Consecutive Prime Numbers
//题目给出一个数,让你求连续的素数相加的和等于这个数的字串个数!(要求是连续的)//例如 41 41 = 2 + 3 + 5 + 7 + 11 + 13 41 = 11 + 13 + 17 41 = 41 这样的素数字串有3个 #include "iostream"#include "cmath"#include "memory.h"using namespace std;i原创 2012-05-02 19:50:49 · 368 阅读 · 0 评论 -
poj 2262 Goldbach's Conjecture
//打表的时候竟然TLE,好囧啊!以为可以节省时间的!//poj上面的题目就是比别的oj上的题目要难!加油! #include "iostream"#include "cmath"#include "memory.h"using namespace std;bool is_primer(int num){ int i, n; if (num == 1 || nu原创 2012-05-03 22:30:32 · 324 阅读 · 0 评论 -
poj 1083 Moving Tables
//参照别人的思路写出来的,哎,发觉自己需要加倍努力来! /* 看哪个房间前经过的桌子最多。 可以把每次移动看作区间,一个点可能被多个区间包含, 看哪个点被最多的区间包含,区间数量即是结果 */#include "iostream"#include "algorithm"#include "memory.h"using namespace std;int ans[410原创 2012-05-04 09:20:13 · 365 阅读 · 0 评论 -
poj 3006 Dirichlet's Theorem on Arithmetic Progressions
#include "iostream"#include "cmath"using namespace std;bool is_primer(int num){ int i, n; if (num == 1) return 0; n = sqrt(double(num)); for (i = 2; i <= n; i++) {原创 2012-05-06 00:28:41 · 387 阅读 · 0 评论 -
poj 1503 Integer Inquiry
#include "iostream"#include "string"using namespace std;int main(){ int i, j, lans, linput, temp, jin; string ans, input; cin >> ans; while (cin >> input && input != "0") {原创 2012-05-06 18:00:47 · 397 阅读 · 0 评论 -
poj 3094 Quicksum
#include "iostream"#include "map"#include "string"using namespace std;map m;int main(){ string input; int i, len, sum; for (i = 0; i < 26; i++) m['A'+i] = i + 1; m[' ']原创 2012-05-06 18:13:26 · 389 阅读 · 0 评论 -
poj 1281 MANAGER
//这题属于简单的模拟题,主要是用两个容器来储存增加进来的cost和删除的cost即可!然后再根据给出的删除清单,在储存删除的容器中进行!//就开始的时候WA了一次,是因为输出格式的问题,值得注意! #include "iostream"#include "string"#include "set"#include "vector"using namespace std;multi原创 2012-05-07 01:35:24 · 862 阅读 · 0 评论 -
poj 1007 DNA Sorting
#include "iostream"#include "string"#include "algorithm"using namespace std;struct Info{ string str; int count;}info[110];bool cmp(Info a, Info b){ return a.count < b.count;}原创 2012-05-07 13:18:23 · 407 阅读 · 0 评论 -
poj 1298 The Hardest Problem Ever
//第一次竟然因为map的映射中写错了一个而WA了一次,哎,粗心! #include "iostream"#include "string"#include "map"#include "cctype"using namespace std;map m;int main(){ m['A'] = 'V', m['B'] = 'W', m['C'] = 'X', m['原创 2012-05-09 00:26:08 · 386 阅读 · 0 评论 -
poj 1045 Bode Plot
/*下面需要推导一下求VR的公式:V2=iR=CR d/dt (VS*cos(wt)-VR*cos(wt+q))=VRcos(wt+q) = CR w (sin(wt+q)-sin(wt))=VRcos(wt+q)下面用到高中数学当中的计算方法,分别令 t=0 和 wt+q=0 ,得到 CRw tan b = 1 和 VR=CRw VS sin b ,然后利用三角函数中原创 2012-05-09 10:00:08 · 1222 阅读 · 0 评论 -
poj 1002 487-3279
//写了一个晚上,用c++的map和string等一系列的库函数,一直都超时,不得不看解题报告了,发觉其他人的处理真的很//奇妙,自己还需要再学习学习才可以!加油,努力! //G++环境下提交 #include "iostream"#include "cstdio"#include "algorithm"using namespace std;char str[100];int原创 2012-05-08 23:06:41 · 1688 阅读 · 0 评论 -
poj 2271 HTML
#include "iostream"#include "string"using namespace std;int main(){ string input; int countnum = 0, i; while (cin >> input) { if (input == "") {原创 2012-05-09 08:42:42 · 648 阅读 · 0 评论 -
poj 1016 Numbers That Count
//由于使用了c++,所以超时了,改为c语言才可以! #include "iostream"#include "string"#include "memory.h"#include "vector"#include "sstream"using namespace std;int c[10];vector v;//储存15个字符串转换的结果 string countnum(s原创 2012-05-08 00:48:00 · 395 阅读 · 0 评论 -
poj 1005 I Think I Need a Houseboat
//给出两点坐标, 求出半径,求面积就可以!简单题! #include "iostream"#include "cmath"using namespace std;const double pi = 4.0 * atan(1.0);const int d = 50;int main(){ int tc, count = 0, ans; double x, y, a原创 2012-05-08 10:23:56 · 410 阅读 · 0 评论 -
poj 1046 Color Me Less
//简单题,由于数组开小了,WA了一次,水啊! #include "iostream"#include "climits"#include "cstdio"using namespace std;struct Info{ int r; int g; int b;};int main(){ Info info[20], temp, ans;原创 2012-05-09 09:23:10 · 471 阅读 · 0 评论 -
poj 1234 Ball Toss
//贡献了一次WA,原因是忽略了下面这句话:“Note that classmate number 1 initially has the ball and tosses it to classmate k. //Thus, number 1 has not yet been tossed the ball and so does not switch the direction he is t原创 2012-05-28 14:01:50 · 1625 阅读 · 0 评论 -
poj 1928 The Peanuts
//照着地图取花生,每次都是取最大的花生数,在限定的步数内,可以取到最多的花生数!用贪心就可以! #include "cstdio"#include "iostream"#include "math.h"using namespace std;int map[60][60];int main(){ int tc, m, n, k, i, j, totaltime, cur原创 2012-05-10 00:02:25 · 1608 阅读 · 0 评论 -
poj 1068 Parencodings
//比较简单的模拟题,只要还原出原来最初始的括号字符串就很容易得出第二种模式的表示! #include "iostream"using namespace std;int s[50], p[30], w[30];int main(){ int tc, n, i, j, k, count; cin >> tc; while (tc--) {原创 2012-05-10 01:24:25 · 649 阅读 · 0 评论 -
poj 2027 No Brainer
#include "iostream"using namespace std;int main(){ int tc, eat, alive; cin >> tc; while (tc--) { cin >> eat >> alive; if (eat < alive) cout << "NO原创 2012-05-11 09:12:02 · 410 阅读 · 0 评论 -
poj 2503 Babelfish
//用一个映射器就很容易解决问题了! #include "iostream"#include "string"#include "map"using namespace std;map m;int main(){ string input, first, second; int pos, i, len; while (getline(cin, input)原创 2012-05-11 09:33:05 · 319 阅读 · 0 评论 -
poj 2551 Ones
#include "iostream"#include "cstdio"using namespace std;int main(){ int n, cnt, ans; while (scanf("%d", &n) != EOF) { ans = 1; cnt = 1; while (1) {原创 2012-05-11 09:02:46 · 501 阅读 · 0 评论 -
poj 2304 Combination Lock
//这题读懂题意就可以:题目是所锁上面的红色的那个刻度走过了的度数是多少?! #include using namespace std;int main(){ int pos1, pos2, pos3, pos4, ans; while (cin >> pos1 >> pos2 >> pos3 >> pos4) { if (pos1 == 0原创 2012-05-30 19:56:40 · 706 阅读 · 0 评论 -
poj 2051 Argus
//这道题就是说,给你个id号,给你个周期,然后每个周期就会输出一次id,对于测试样例,200先输出一次2004,然后300输出2005,400的时候就是2004,600时候两个都要输出,那么按id的升序输出2004然后2005,输出了5个数据了,结束了···//前面说的全是废话,但是需要注意其周期为0的时候,就相当于优先级是最高的,所以总是输出其周期为0的且id号最小的那个! #includ原创 2012-05-31 08:22:45 · 1094 阅读 · 0 评论 -
poj 2302 Traditional BINGO
//就是按下面的数一个一个处理,如果是已有的牌则标记上,如果有任意横排,竖排,或斜排的数都被标记了则游戏结束#include using namespace std;int bingo[5][5];int num[75];int main(){ int tc, i, j, k, c; bool flag1, flag2, flag3, flag4; cin原创 2012-05-30 20:42:21 · 768 阅读 · 0 评论 -
poj 1326 Mileage Bank
#include #include using namespace std;int main(){ string str1, str2, str3; int m, ans = 0; while (cin >> str1) { if (str1 == "0") { cout << ans <原创 2012-06-01 09:38:55 · 657 阅读 · 0 评论 -
poj 2424 Flo's Restaurant
//这题模拟题搞死人了:首先桌子是分类的,如果你来的人数是1或者2,只可以坐 two-seat tables类型,如果你来的人数是2或者3人,只可以坐// four-seat tables 类型,如果来的人数是5或者6人,只可以坐 six-seat tables类型,就算其他的桌子类型有空出来了,你也不可以坐,你只可以//等你所需要的那种类型;第二个值得注意的地方就是:they have to原创 2012-06-01 01:37:06 · 1350 阅读 · 0 评论 -
poj 1922 Ride to School
/*1,时间为负数的不用管,直接去掉,因为如果你可以追得上他(A),那么说明你的速度比他快,那么你不会去跟他(A)走的,如果追不上,那更加不用说2,找一个达到时间最少的,输出这个答案就行了,,因为用时最少那么他一定会追上你,你一定会最后跟着他走,他到达的时间也就是你达到的最少时间了(这里的t=s/v+t0)3,精度问题,比如得到1.1,你就应该输出2,那么就是if(aa-(int)aa>0.原创 2012-06-01 18:57:33 · 618 阅读 · 0 评论 -
poj 1786 Bridge Hands
//比较简单的一道模拟题,模拟扑克牌的派发! #include #include #include #include #include #include using namespace std;struct Info//扑克牌的牌面 { char num; char color;}card;//各个选手的牌 vector n;vector e;vec原创 2012-06-01 20:47:33 · 688 阅读 · 0 评论 -
poj 2000 Gold Coins
//简单的数学题! #include "iostream"using namespace std;int main(){ int days, i, ans, sum; while (cin >> days && days) { sum = 0; ans = 0; for (i = 1; ; i++)原创 2012-05-15 12:49:26 · 545 阅读 · 0 评论 -
poj 2017 Speed Limit
#include "iostream"using namespace std;int main(){ int num, i, s, t, temp, ans; while (cin >> num && num != -1) { temp = ans = 0; for (i = 0; i < num; i++)原创 2012-05-15 21:38:56 · 451 阅读 · 0 评论 -
poj 2081 Recaman's Sequence
//这样的题很容易超时,所以就开两个数组,一个保存结果,一个保存已经出现过的结果,这样就容易判断了,//如果再倒过来判断是否出现在字符串出现,就超时了! /*#include "iostream"#include "memory.h"using namespace std;int a[500005];bool flag[20000000];int main(){ int原创 2012-05-15 23:22:29 · 429 阅读 · 0 评论 -
poj 1118 Lining Up
//判断共线的最大点数有多少个?!根据斜率判断,为避免斜率不存在的情况,改为乘法比较简单一点! #include #include using namespace std;struct Info{ int x; int y;}cor[705];int main(){ int n, i, j, k, ans, max; double k1, k2;原创 2012-06-05 01:00:34 · 639 阅读 · 0 评论