随笔分类 -  POJ

摘要:Terrible SetsTime Limit: 1000MSMemory Limit: 30000KTotal Submissions: 2428Accepted: 1215DescriptionLet N be the set of all natural numbers {0 , 1 , 2 , . . . }, and R be the set of all real numbers. wi, hi for i = 1 . . . n are some elements in N, and w0 = 0. Define set B = {< x, y > | x, y ∈ 阅读全文
posted @ 2012-08-16 20:22 加拿大小哥哥 编辑
摘要:2723:不吉利日期时间限制:1000ms内存限制:65536kB描述在国外,每月的13号和每周的星期5都是不吉利的。特别是当13号那天恰好是星期5时,更不吉利。已知某年的一月一日是星期w,并且这一年一定不是闰年,求出这一年所有13号那天是星期5的月份,按从小到大的顺序输出月份数字。(w=1..7)输入输入有一行,即一月一日星期几(w)。(1#include #include using namespace std;int ans[12];int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};int fun(int num){ int... 阅读全文
posted @ 2012-08-16 15:20 加拿大小哥哥 编辑
摘要:2712:细菌繁殖Time Limit:1000msMemory Limit:65536kBDescription一种细菌的繁殖速度是每天成倍增长。例如:第一天有10个,第二天就变成20个,第三天变成40个,第四天变成80个,……。现在给出第一天的日期和细菌数目,要你写程序求出到某一天的时候,细菌的数目。Input第一行有一个整数n,表示测试数据的数目。其后n行每行有5个整数,整数之间用一个空格隔开。第一个数表示第一天的月份,第二个数表示第一天的日期,第三个数表示第一天细菌的数目,第四个数表示要求的那一天的月份,第五个数表示要求的那一天的日期。已知第一天和要求的一天在同一年并且该年不是闰年,要 阅读全文
posted @ 2012-08-16 13:45 加拿大小哥哥 编辑
摘要:2792:集合加法ViewSubmitStatisticsClarifyTime Limit:3000msMemory Limit:65536kBDescription给出2个正整数集合A = {pi | 1 #include using namespace std;int s1[10001],s2[10002];int main(){ int i,j,k,T; cin>>T; while(T--) { int ans = 0; memset(s1,0,sizeof(s1)); memset(s2,0,sizeof(s2)); ... 阅读全文
posted @ 2012-08-16 12:52 加拿大小哥哥 编辑
摘要:2755:神奇的口袋Time Limit:10000msMemory Limit:65536kBDescription有一个神奇的口袋,总的容积是40,用这个口袋可以变出一些物品,这些物品的总体积必须是40。John现在有n个想要得到的物品,每个物品的体积分别是a1,a2……an。John可以从这些... 阅读全文
posted @ 2012-08-16 12:39 加拿大小哥哥 编辑
摘要:放苹果Time Limit: 1000MSMemory Limit: 10000KTotal Submissions: 21050Accepted: 13423Description把M个同样的苹果放在N个同样的盘子里,允许有的盘子空着不放,问共有多少种不同的分法?(用K表示)5,1,1和1,5,1... 阅读全文
posted @ 2012-08-16 11:07 加拿大小哥哥 编辑
摘要:Red and BlackTime Limit: 1000MSMemory Limit: 30000KTotal Submissions: 17061Accepted: 8996DescriptionThere is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can& 阅读全文
posted @ 2012-08-15 23:48 加拿大小哥哥 编辑
摘要:1923. Tanning SalonTime Limit: 1.0 Seconds Memory Limit: 65536KTotal Runs: 924 Accepted Runs: 556Tan Your Hide, Inc., owns several coin-operated tanning salons. Research has shown that if a customer arrives and there are no beds available, the customer will turn around and leave, thus costing the c. 阅读全文
posted @ 2012-08-15 21:25 加拿大小哥哥 编辑
摘要:1601. Box of BricksTime Limit: 1.0 Seconds Memory Limit: 65536KTotal Runs: 5007 Accepted Runs: 1950Little Bob likes playing with his box of bricks. He puts the bricks one upon another and builds stacks of different height. "Look, I've built a wall!", he tells his older sister Alice. &q 阅读全文
posted @ 2012-08-15 19:20 加拿大小哥哥 编辑
摘要:1547. To and FroTime Limit: 1.0 Seconds Memory Limit: 65536KTotal Runs: 885 Accepted Runs: 692Mo and Larry have devised a way of encrypting messages. They first decide secretly on the number of columns and write the message (letters only) down the columns, padding with extra random letters so as to. 阅读全文
posted @ 2012-08-15 18:11 加拿大小哥哥 编辑
摘要://注意只有一组数据,否则OLE //题意:输出字符串的全排列 #include <iostream>#include <string>#include <algorithm>#include <cstdlib>#include <queue>//less算子 using namespace std;int main(){ int i,j,k; char s[210]; //while(1) { memset(s,0,sizeof(s)); cin>>s; // if(s=="NULL") // bre 阅读全文
posted @ 2012-08-14 21:18 加拿大小哥哥 编辑
摘要://poj1011无限wa,做道简单的,直接暴力竟然AC啦 //大意:输出所有满足a^3 = b^3 + c^3 + d^3 的a #include <iostream>#include <cstdlib>using namespace std;int m(int m){ return m*m*m;}int main(){ int i,j,k,n,p; cin>>n; for(p=6;p<=n;p++) for(i=2;i<=n-1;i++)//已经保证bcd互不相等 for(j=i+1;j<=n-1;j++) for(k=j+1;k< 阅读全文
posted @ 2012-08-14 20:58 加拿大小哥哥 编辑
摘要://KMP,对vector单个赋值不懂,只能用c语言形式拉 //大致题意:字符串s有多少个子串既是前缀又是后缀 #include <iostream>#include <string>#include <cstring>#include <cstdlib>using namespace std;const int N = 400010;int next[N] = {0},a[N] = {0};void get_next(string s) { int i,j; i=0; j=-1; next[0]=-1; while(i<s.length( 阅读全文
posted @ 2012-08-14 17:14 加拿大小哥哥 编辑
摘要:#include #include using namespace std;int res[8001]; int main(){ int i,j,k,T; int ans[8001]; while(cin>>T) { int Max = -1, Min = 8001; memset(ans,-1,sizeof(ans));//下标为区间,值为颜色 memset(res,0,sizeof(res));//下标为颜色,值为组数 for(i=1; i>a>>b>>c; if(aMax) ... 阅读全文
posted @ 2012-08-13 10:37 加拿大小哥哥 编辑
摘要:#include#include#include#define N 8000int flag;int num[N+1]={0};struct intervaltree{ int l,r,cover; struct intervaltree *lchild,*rchild;};void initial(struct intervaltree *T)//可以不要了,建树和统计的时候就会将其初始化了 { if(T==NULL) return ; T->cover=-1; initial(T->lchild); initial(T->rchild);}struct ... 阅读全文
posted @ 2012-08-12 19:12 加拿大小哥哥 编辑
摘要:Web NavigationTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 23963Accepted: 10692DescriptionStandard web browsers contain features to move backward and forward among the pages recently visited. One way to implement these features is to use two stacks to keep track of the pages that can be 阅读全文
posted @ 2012-08-10 12:13 加拿大小哥哥 编辑
摘要://用c语言做的话会很快,主要锻炼一下string的使用 ,但是老提示reverse未声明 #include #include #include #include using namespace std;int main(){ int i,T; cin>>T; while(T--) { string s; /* while(cin>>s) { if(s=="\n") { cout>s; for(i=s.length()-1;i>... 阅读全文
posted @ 2012-08-10 11:14 加拿大小哥哥 编辑
摘要://注意下控制格式 #include #include #include using namespace std;bool is_match(queue q,int num){ int i,j,k; stack s; for(i=1;i>T,T) { while(1) { queue s; int num,temp=1;//temp必须初始化为非零值,否则下一次的temp直接为0 for(i=1;i>num; if(num==0) ... 阅读全文
posted @ 2012-08-10 09:47 加拿大小哥哥 编辑
摘要://组数:卡塔南公式 //大致题意:输出所有可能出战顺序 #include #include #include using namespace std; bool is_ok(int *a,int n){ int i,j,k=0; stack s; for(i=1;i>T; while(T--) { cin>>n; for(i=0;i<n;i++) a[i] = i+1; do { if(is_ok(a,n)) ... 阅读全文
posted @ 2012-08-09 17:01 加拿大小哥哥 编辑
摘要://Huffman树的构造就不赘述了,使用优先队列每次选择队头的两个数并将其出列,相加后将结果放入队列中,直到队列为空为止.#include <iostream>#include <queue>#include <vector>#include <string>#include <iomanip>#include <algorithm>using namespace std;int main(){ int i,j,k; string s; while(1)//cin遇到空格结束 { getline(cin,s); if(s 阅读全文
posted @ 2012-08-08 19:42 加拿大小哥哥 编辑