![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
POJ
文章平均质量分 51
Bob_N
这个作者很懒,什么都没留下…
展开
-
POJ 1016
<br />//简单模拟,重点掌握string cin cout #include <iostream> #include <string> using namespace std; string calc(string str) { int i, j = 0; int num[10] = {0}; char inv[81]; for(i = 0; i < str.length(); i++) //c++ ! { num[str[i]-'0']++; }原创 2010-11-29 19:51:00 · 619 阅读 · 0 评论 -
poj 1548 (贪心 会场安排)
<br />//典型的活动会场安排问题 //c中竟然不能用bool? #include <stdio.h> #include <stdlib.h> #define csMax 5001 struct data { int length; int weight; int flag; }; struct data sticks[csMax]; //c中struct不能省,c++中可以! int cmp(const void *a, const void *b) { struc原创 2010-12-26 10:28:00 · 1308 阅读 · 1 评论 -
POJ 2350 (注意字符%的输出)
<br />}//唯一要主义的是字符%的输出 printf("%%"); #include <stdio.h> int main() { int i; int nCase, nNum, nGrade[1001]; int temp, average; while (1==scanf("%d", &nCase)) { while(nCase--) { temp=0; scanf("%d", &nNum); for(i=0; i<nNum原创 2010-11-06 23:03:00 · 528 阅读 · 0 评论 -
POJ 1656 Counting Black
<br />//简单模拟 #include <stdio.h> #define csMax 101 int main() { int i, j, k; int nCommands; int x[csMax], y[csMax], L[csMax]; int flag[csMax][csMax]={0}; char command[csMax][6]; int a1, b1, count, temp; while (1==scanf("%d", &nC原创 2010-11-07 12:00:00 · 460 阅读 · 0 评论 -
POJ 1002
qsort的运行,具体看MSDN 一个是二位数组的qsort用法:1intcompare( constvoid*arg1, constvoid*arg2 ) 2{ 3 returnstrcmp((char*)arg1, (char*)arg2 ); 4} 5intarr[n][11]; 6qsort(arr, n, sizeof(arr[0]), compare);#include #include #include #define csMax 100000+1 char nN原创 2010-11-12 19:24:00 · 449 阅读 · 0 评论 -
POJ 1007
/* T>G>C>A CCCGGGGGGA 9 AACATGAAGG 3+5+2=10 GATCAGATTT 4+4+2+1=11 ATCGATGCAT 6+2+2+3+2+1=16 TTTTGGCCAA 24+8+4=36 TTTGGCCAAA 21+10+6=37 */ #include #include #include struct sortNum { char str[51]; int count; }; struct sortNum t[1原创 2010-11-12 21:19:00 · 451 阅读 · 0 评论 -
POJ 3664 (qsort 快排)
<br />//2010-11-15 #include <stdio.h> #include <stdlib.h> struct vote { int firstRound; int secondRound; int ID; }; struct vote arr[50001]; int cmp(const void *a, const void *b) {//必须这样写!用“->”错! 明白此处 “.” 和“ ->” 的区别!!!! return (*(s原创 2010-11-15 21:20:00 · 1239 阅读 · 0 评论 -
POJ 1840 (哈希)
<br />思路一、排序暴力<br />//a1x1 3+ a2x2 3+ a3x3 3+ a4x4 3+ a5x5 3=0 <br />//拆成a3x33+ a4x43+ a5x53 = -(a1x1 3+ a2x2 3)<br />#include <stdio.h><br />#include <stdlib.h><br /> <br />int cmp(const void *a, const void *b)<br />{<br /> return *(int *)a - *(int原创 2010-11-15 17:12:00 · 486 阅读 · 0 评论 -
POJ 1318
<br />//快排 充分利用qsort()函数! #include <stdio.h> #include <string.h> #include <stdlib.h> int cmp_w(const void *a, const void *b) { return strcmp((char *)a, (char *)b); } int cmp_str(const void *a,const void *b) { return *(char *)a-*(char *)b;原创 2010-11-15 17:16:00 · 705 阅读 · 0 评论 -
POJ 3650 (尚待研究) 2010-11-15
<br />考察基本功<br />1、getchar <br />语法: <br /> #include <stdio.h><br /> int getchar( void );<br />getchar()函数从STDIN(标准输入)获取并返回下一个字符,如果到达文件尾返回EOF.<br />2、gets <br />语法: <br /> #include <stdio.h><br /> char *gets( char *str );<br />gets()函数从STDIN(标准输入)读取字符并原创 2010-11-15 21:19:00 · 585 阅读 · 0 评论 -
POJ 2313
V = (|A(1) – B(1)| + |A(2) – B(2)| + ... + |A(N) – B(N)|) + (|B(1) – B(2)| + |B(2) – B(3)| + ... +|B(N-1) – B(N)|)<br />将公式简单变形就可以推出b[0]=a[0]和b[n-1]为区间[a[n-1],b[n-2](不知道a[n-1]与b[n-2]大小关系)内的任意一个数或者b[n-1]=a[n-1]和b[0]为区间[a[0],b[1]]区间内的任意一个数,而考虑b[i],即要使 |b[i]-原创 2010-11-20 19:34:00 · 998 阅读 · 0 评论 -
POJ 1799
<br />学习点 PI=acos(-1..0) sin(x), cos(x), x是弧度!<br />#include <stdio.h> #include <math.h> //#define PI 3.1415926535 #define PI acos(-1.0) //PI的表示还是值得学习的 int main() { int nCase, nCaseNum; double R, r; int n; nCaseNum=0; while (1==scanf("%d"原创 2010-11-17 18:04:00 · 549 阅读 · 0 评论 -
POJ 1323 简单贪心
<br />#include <stdio.h> #include <string.h> int main() { int i; int n, m; int nCard, flag[1001]; int caseNum = 1; int count, res, temp; while (scanf("%d %d", &n, &m) != EOF, n, m) { memset(flag,0, sizeof(flag)); for(i = 0; i原创 2010-11-21 11:52:00 · 521 阅读 · 0 评论 -
POJ 2726 + 1828
输入n个二元组(xi,yi),统计有多少个二元组(xk,yk)满足:对于任意xi yk; 对于任意yi xk ( n原创 2010-12-11 20:01:00 · 946 阅读 · 0 评论 -
1604 Just the Facts (高精度) (?)
#include using namespace std; const int maxn = 2500; int nFactorial[maxn]; int funcSolve(int n); int main() { int num; while(1 == scanf("%d", &num)) { int result = funcSolve(num); printf("%5d -> %d/n", num, result); //输出要注意! }原创 2010-12-11 18:44:00 · 688 阅读 · 0 评论 -
POJ 题目分类
争取做完上面所有的题目。转载 2010-12-10 19:17:00 · 3410 阅读 · 0 评论 -
POJ 1350 Cabric Number Problem
<br />模拟得我吐血!<br />有空理理思路,重新做一遍!原创 2010-11-29 22:12:00 · 644 阅读 · 0 评论 -
POJ 1328 贪心
<br />#include <iostream> #include <algorithm> #include <math.h> #define csMax 1001 using namespace std; struct LocationData { double nFrom; double nTo; }; LocationData dd[csMax]; int nCaseNum, nIslandNum; double d; double nX[csMax], n原创 2010-12-01 20:49:00 · 618 阅读 · 0 评论 -
POJ 2014 Flow Layout 模拟
<br />/*POJ 2014 Flow Layout 模拟*/ #include <iostream> using namespace std; int main() { int maxGiven; int width_in, height_in; int width_curr, height_curr; int width_max, height_max; while(1 == scanf("%d", &maxGiven)) { if(maxGiven原创 2010-12-04 15:35:00 · 570 阅读 · 0 评论 -
poj 3761 Panda's Birthday Present (数学公式推导~~推?)
<br />/*推导公式:(p+q+10)/7 */ #include <iostream> using namespace std; int main() { int nCase; int p, q; double result; scanf("%d", &nCase); while(nCase--) { scanf("%d %d", &p, &q); result= (p + q + 10) / 7.0; printf("%.3lf/n",原创 2010-12-04 16:43:00 · 956 阅读 · 0 评论 -
poj 3507 (%g的使用)
<br />/* %g(%G) 浮点数不显无意义的零"0" */ #include <iostream> #include <algorithm> using namespace std; void funcInput(); void funcDealData(); bool cmp(const int &a, const int &b); void funcOutput(); int num[7]; int judge, sum; int main() {原创 2010-12-05 09:47:00 · 1038 阅读 · 0 评论 -
poj 3518 Prime Gap
<br />#include <iostream> #include <math.h> using namespace std; const int csMax = 1299709; bool isPrim(int a); int main() { int num, maxGap; while(1 == scanf("%d", &num), num) { if(isPrim(num)) { maxGap = 0;; } else原创 2010-12-04 23:35:00 · 636 阅读 · 0 评论 -
poj 3372 (使用num & (num-1) 判断num是否为2的k次方)
<br />/*注意&的使用 num & (num-1) 判断num是否为2的k次方 证明看:http://hi.baidu.com/findthegateopen/blog/item/03e5802e19f1ea301e3089f9.html */ #include <iostream> using namespace std; int main() { int num; while(1 == scanf("%d", &num)) { printf((num &原创 2010-12-05 10:23:00 · 2927 阅读 · 0 评论 -
POJ 3543 iChess (水题,精度注意)
<br />/*题意理解+细节+精度*/ #include <iostream> #include <cmath> using namespace std; int main() { int b, w; int size; while(2 == scanf("%d %d", &b, &w)) { if(b == 0 && w == 0 ) { printf("Impossible/n"); } else { if(w ==原创 2010-12-06 20:45:00 · 773 阅读 · 0 评论 -
POJ 1781 In Danger (约瑟夫问题)
<br />思路:见代码注释。<br /> <br />#include <iostream> #include <cmath> using namespace std; int nPersons, suriverNum; int funcInput(); void funcWorkout(); void funcOutput(); int main() { while(funcInput()) { funcWorkout(); funcOutput(原创 2010-12-06 18:22:00 · 825 阅读 · 0 评论 -
POJ 3981 字符串替换 (string的基础使用)
<br />1、c++中字符串的操作头文件 #include <string><br />2、getline<br />3、find<br /> <br />#include <iostream> #include <string> //c++中字符串操作的头文件! using namespace std; int main() { string str; while(getline(cin, str)) //getlin 函数 { int start = str原创 2010-12-08 19:40:00 · 1363 阅读 · 1 评论 -
POJ 1852 Ants
<br />2010-12-10 15:44:04<br /> <br /> <br /> <br />/*功能: 函数返回参数arg的绝对值。 1、fabs 语法: #include <math.h> double fabs( double arg ); 2、abs 语法: #include <stdlib.h> int abs( int num ); */ #include <iostream> using namespace s原创 2010-12-10 15:43:00 · 924 阅读 · 0 评论 -
POJ 1496 + 1850 (数论-排列组合) (?)
a -> 1 <br /> b -> 2 <br /> . <br /> . <br /> z -> 26 <br /> ab -> 27 <br /> ac -> 28 <br /> . <br /> . <br /> az -> 51 <br /> bc -> 52 <br /> . <br /> . <br /> vwxyz -> 83681/*理解是关键,数论题*/ #include <原创 2010-12-10 21:39:00 · 801 阅读 · 0 评论 -
POJ 1065 (贪心)
1、qsort函数的应用int cmp(const void *a, const void *b){ struct data *c = (struct data *)a; //注意struct不能省! struct data *d = (struct data *)b; //! if((c->length) == (d->length)) return c->weight - d->weight; else return c->length - d->length;}//典型的活动会场安排问题 //c原创 2010-11-21 16:14:00 · 529 阅读 · 0 评论