- 博客(44)
- 资源 (4)
- 收藏
- 关注
原创 poj 1835 宇航员
//这一模拟题,我之前有接触过,我记得刚开始不会做,然后看了别人的代码,然后再自己写一遍出来,现在再来做的时候,发现自己原来还不会做,所以这次我没有看别人的代码,完全靠自己//的思考解决了这一题!事实证明:没有经过自己思考的东西是记不住和学不会的,以后需要勤动动脑才可以!谨记!//最开始我思考这一模拟题的时候,卡住我思路的是:一直想将宇航员的状态在数组中一一表示出来,然后就可以轻松的求出他的坐
2012-04-30 12:23:40 1386 1
原创 poj 2524 Ubiquitous Religions
//这题是我接触并查集的第二题,好顺利AC了!//题目给出几个数据对,在同一个数据对中的人的信仰是相同的,需要你求出在给定的人数中,有几种信仰!//将有相同信仰的人组成一颗树,然后统计数的棵树,再加上还有统计的人数,就可以得出了答案!#include "iostream"#include "memory.h"#include "set"using namespace std;con
2012-04-27 19:17:04 513
原创 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 362
原创 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 444 1
原创 zoj 1090 The Circumference of the Circle
//利用余弦和正弦公式就可以很容易求出半径了!#include "iostream"#include "cmath"#include "cstdio"using namespace std;const double pi = 3.141592653589793;int main(){ double x1, y1, x2, y2, x3, y3; double a2, b2,
2012-04-27 10:00:58 523
原创 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 474
原创 zoj 1089 Lotto
#include "iostream"#include "cstdio"using namespace std;int main(){ int num[14], n, i, a, b, c, d, e, f, flag = 0; while (cin >> n && n) { if (flag != 0) cout << endl; for (i = 0; i < n
2012-04-25 23:11:48 512
原创 zoj 1086 Octal Fractions
//小数的高精度计算!利用辗转相除就可以!#include "iostream"#include "cstdio"#include "string.h"using namespace std;const int maxsize = 100;int main(){ char input[maxsize], ans[maxsize];//输入和结果的储存! int len, i,
2012-04-24 23:09:05 737
原创 zoj 3202 Second-price Auction
//找出第二大的数和第一大的数的位置!#include "iostream"#include "memory.h"using namespace std;int p[110];int main(){ int tc, n, i, max, smax, pos; cin >> tc; while (tc--) { cin >> n; memset(p, 0, sizeo
2012-04-19 09:53:30 616
原创 zoj 3607 Lazier Salesgirl
#include "iostream"#include "memory.h"#include "iomanip"#include "limits.h"using namespace std;int p[1010], t[1010];int main(){ int i, num; double w, avg, testcase, sum, time; cin >> testc
2012-04-16 20:50:04 1615
原创 zoj 3603 Draw Something Cheat
//本来就是一道简单题,但是没有很好的理解题目,将重复的字符给去掉,所以一直都是WA!//下面参考了别人的代码写出了的!囧!#include "iostream"#include "string"using namespace std;string str[25];int main(){ int testcase, i, j, k, time; cin >> testcase
2012-04-16 12:27:07 1610
原创 zoj 3600 Taxi Fare
#include "iostream"using namespace std;int main(){ int testcase; double s1, s2, ans, d, t; cin >> testcase; while (testcase--) { cin >> d >> t; s1 = s2 = ans = 0; if (d <= 3) { s1
2012-04-15 10:09:04 1452
原创 zoj 3610 Yet Another Story of Rock-paper-scissors
#include "iostream"#include "string"using namespace std;int main(){ int testcase; string str1, str2, str3; cin >> testcase; while (testcase--) { cin >> str1 >> str2 >> str3; cout << str2
2012-04-15 09:53:12 1314
原创 zoj 3609 Modular Inverse
//这题的意思就是:求一个最小的正整数x,使a乘以x对m的取余等于1对m的取余!#include "iostream"using namespace std;int main(){ int testcase, i, a, m; bool flag; cin >> testcase; while (testcase--) { cin >> a >> m; flag = f
2012-04-15 09:48:39 2237
原创 zoj 3191 Strange Clock
//直接就可以写出来了,很简单的一题!#include "iostream"using namespace std;int main(){ int a; while (cin >> a && a != -1) { if (a == 0) cout << "Exactly 3 o'clock" << endl; else if (a > 0 && a < 30)
2012-04-13 13:17:45 643
原创 zoj 3519 Who is the Smartest Man
//简单的贪心题!主要是先对输入的数组进行排序!#include "iostream"#include "algorithm"#include "memory.h"using namespace std;int points[510];int main(){ int N, IP, i, count; while (cin >> N >> IP) { memset(poi
2012-04-13 09:41:52 559
原创 zoj 3492 Kagome Kagome
//这题需要注意就是:它给出的名字的排序是逆序来的!#include "iostream"#include "string"using namespace std;int main(){ int testcase, num, i, ans; string name, str[110]; cin >> testcase; while (testcase--) { cin >
2012-04-12 19:43:44 907 1
原创 zoj 3498 Javabeans
//一开始思考这题的时候,以为是用动态规划来做的,但是再仔细分析,//找不出动态规划的式子,到最后只有百度了!/*题目大意 有n个盒子,编号1到n,第i个盒子里面装有i个javabeans,每次选择一个数字, 有javabeans的个数大于此数字的盒子可以每次拿出那个数字的javabeans, 要拿走左右的javabeans,需要多少次 题目分析 二分法,每次将不小于n/2个ja
2012-04-12 18:49:39 906
原创 zoj 3124 Celebrity jeopardy
//好简单的一题!#include "iostream"#include "string"using namespace std;int main(){ string str; while (getline(cin, str)) { cout << str << endl; }}
2012-04-11 18:57:29 768
原创 zoj 3100 ICPC Score Totalizer Software
//题意:求平均数,去掉一个最高分和一个最低分,再计算平均数!#include "iostream"#include "memory.h"#include "algorithm"using namespace std;int scores[110];int main(){ int num, i, sum, average; while (cin >> num && num)
2012-04-05 10:59:25 517
原创 zoj 2988 Conversions
//单位之间的转换,用一个map映射器就很容易解决!#include "iostream"#include "string"#include "map"#include "iomanip"using namespace std;int main(){ int testcase, count = 0; double n, ans; string measurement; ma
2012-04-05 10:31:56 613
原创 zoj 2897 Misspelling
#include "iostream"#include "string"using namespace std;int main(){ int testcase, count = 0 , pos; string input; cin >> testcase; while (testcase--) { cin >> pos >> input; count++; inp
2012-04-04 16:44:32 529
原创 zoj 2965 Accurately Say "CocaCola"!
//这题作一个简单的分析就可以看出其中的规律了,很简单的规律!#include "iostream"using namespace std;int main(){ int testcase, p; cin >> testcase; while (testcase--) { cin >> p; switch(p) { case 1: cout << "7" << e
2012-04-04 16:28:57 1026
原创 zoj 2947 Abbreviation
#include "iostream"#include "string"using namespace std;string input[5];int main(){ int testcase, i, num1, num2; string temp1, temp2; cin >> testcase; while (testcase--) { for (i = 0; i
2012-04-04 15:43:23 549
原创 zoj 2932 The Seven Percent Solution
#include "iostream"#include "string"#include "map"using namespace std;int main(){ int i, len; string input, ans; mapm; m[' '] = "%20", m['!'] = "%21", m['$'] = "%24", m['%'] = "%25", m['(']
2012-04-04 12:30:48 592
原创 zoj 2850 Beautiful Meadow
//简单题,就是对给出的两个条件进行判断即可!#include "iostream"using namespace std;int meadow[15][15];int main(){ int i, j, N, M; bool flag1, flag2; while (cin >> N >> M && N && M) { flag1 = flag2 = false;
2012-04-04 11:06:49 514
原创 zoj 2744 Palindromes
//这题主要是找回文字符串的个数,可以用DP来做(贴一下别人的代码,学习学习),也可以用分治方法做!//下面是参照别人的代码再自己实现的,因为之前接触的比较少,所以还不是很熟悉这些题的做法!//希望可以学到东西!#include "iostream"#include "string"using namespace std;string s;int len, count;void
2012-04-04 09:44:45 919
原创 zoj 2795 Ambiguous permutations
//这题的大意为:给出一个数组,需要你验证这个数组是否与自己的逆置换数组相等!//逆置换:例如给出数组1,4,3,2,而原来的数组顺序为1, 2, 3, 4,就根据给出的数组作为原来数组排序的下标,//得出的逆置换为1, 4, 3, 2,与给出的数组相等,所以就为模糊排序!#include "iostream"#include "memory.h"using namespace std;
2012-04-04 09:15:18 523
原创 zoj 2781 Rounders
//这题的大意就是对输出的数字进行判断,对于每一位数字,凡是满5就进1!#include "iostream"#include "string"#include "cmath"using namespace std;int main(){ int testcase, i, len, temp1, temp2, ans; string num; cin >> testcase;
2012-04-03 23:46:15 430
原创 zoj 2773 Triangular Sums
//很简单,求和,求加权和!#include "iostream"using namespace std;int sum(int num)//{ int temp, i; temp = 0; for (i = 1; i <= num + 1; i++) temp += i; return temp;}int main(){ int i, testcase, n, c
2012-04-03 22:51:27 408
原创 zoj 2679 Old Bill
//这题的大意是:给定你一个五位数,但头和尾的数缺失,需要你找出头和尾的两个数(注意:头的数不为0)//如果有多种情况的,就输出其最大的那个数!#include "iostream"#include "algorithm"using namespace std;struct Info{ int firstnum; int endnum; int price;}info[100
2012-04-03 16:28:05 544
原创 zoj 2659 Box
/*判断六个矩形能否组成长方体,我们只要找到一组充要条件去判断即可这里用的就是把边排序,然后根据对面必相等,相邻面有边重合判断 *///看了别人代码,再自己写出来的,无什么心情写这一题!囧!#include "iostream"#include "stdio.h"#include "algorithm"using namespace std;struct Rect{ int
2012-04-03 12:10:56 522
原创 zoj 2554 Brownie Points
//刚开始,读了很久题目,也不是很明白题目的要求是什么!经过再三阅读,才明白!//题目要求是:在给出的这么多个坐标中,取中间的坐标为原点,然后分别统计落在第一和第三象限,//第二和第四象限的坐标点个数!#include "iostream"using namespace std;struct Info{ int x; int y;};Info info[200010];i
2012-04-03 09:51:11 392
原创 zoj 2548 Prerequisites?
//这题属于简单题,只要你有耐心读懂题目就很简单了!#include "iostream"#include "string"#include "memory.h"using namespace std;string chosencourses[110];//已选课程string categorycourses[110];//分类中的课程bool flag[110];int ma
2012-04-02 12:16:14 482
原创 zoj 2514 Generate Passwords
//题目比较简单,就按题目的要求,如果密码有得修改的就修改,如果没有就输出!#include "iostream"#include "string"#include "map"#include "vector"using namespace std;struct Info{ string name; string password;};int main(){ int
2012-04-02 10:25:52 524
原创 zoj 2482 IP Address
//这题主要是将IP地址转换为十进制表示!#include "iostream"#include "string"#include "cmath"using namespace std;int main(){ int N, i, j, k, sum, output[4]; string input, temp[4]; cin >> N; for (i = 0; i < N;
2012-04-01 10:46:38 398
原创 zoj 1733 Common Subsequence
/*abcfbc abfcabprogramming contest abcd mnpabcdefgh abdcdaefaaaaaabbbbbbccccccdddddd adabcdaaaaaabbbbbbccccccdddddd adaaabbccdd*///这题主要是从一个字符串中找出另一个字符串中最长的字串!要求在这个字符串中的下标序号为递增顺序!//用动态规划来做就简单
2012-04-01 10:43:05 401
原创 zoj 1797 Least Common Multiple
//求最小公倍数!对输入的数据一对一对的进行求解,再与输入的第三个数据进行求解即可!#include "iostream"#include "algorithm"using namespace std;int main(){ int testcase, num, i, j, temp1, temp2, temp3; cin >> testcase; while (testcase
2012-04-01 10:42:06 564
原创 zoj 1716 Get Many Persimmon Trees
//这题主要是给定一个矩形的宽度和高度,在给出的这个矩形的面积中,//求出包含最多的树的数目,最开始WA了很多次,因为没有考虑到取值的范围!//下面主要用枚举的方法,一个一个的矩形进行枚举!#include "iostream"#include "memory.h"#include "algorithm"using namespace std;struct treespos{
2012-04-01 10:41:21 494
原创 zoj 1713 Haiku Review
//这题属于字符串简单题,就是找出输入字符串的元音字符(a, e, i, o, u, y),//连续两个元音当做一个元音来计算!// If the haiku is not correct, you must output the number of the first line that has the wrong number of syllables.//一开始WA了一次,就是错解了这
2012-04-01 10:39:49 917 1
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人