• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
tmeteorj
Nothing is so big that it is impossible to get over, and hurt only serves to make us stronger. 没有什么事是大到无法战胜的,痛苦也只会让我们变得更加坚强。
博客园 | 首页 | 新随笔 | 新文章 | 联系 | 订阅 订阅 | 管理

随笔分类 -  ACM 模拟&枚举

上一页 1 2 3 下一页

 
POJ 3193
摘要:题意:判断一些句子是不是另一些句子的前缀,并统计是的个数。题解:将被匹配串读入结构体中排序,然后对于每个匹配串,通过二分在结构体中找。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 const int M=1005,N=10005; 6 struct data 7 { 8 char s[100]; 9 bool operator<(const data &ne)const10 {11 return st 阅读全文
posted @ 2012-10-07 16:48 tmeteorj 阅读(242) 评论(0) 推荐(0)
POJ 1309
摘要:题意:m个椰子,n个人,使得这n个人按次序醒来后能够将剩余的椰子分成n份多1,然后将1扔给猴子,自己拿走n份中的一份(这里的n一旦确定就不会改变),n次之后,剩余的椰子还能被n整除,求最大满足条件的n。题解:考虑第一次m%n==1,所以对m-1分解质因数,即m-1的所有非1的约数都能在第一次分椰子的时候满足条件,然后枚举所有m-1的约数,最多2000多个,找出最大的。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 c 阅读全文
posted @ 2012-10-07 16:07 tmeteorj 阅读(324) 评论(0) 推荐(0)
POJ 1117
摘要:题意:给出一个n,求所有的x+y=n且y是x长度仅差1的子序列。题解:分情况讨论,设y是x剔除第i位得到的数,1)若i>lenth(n)/2,y=x/10^i*10^(i-1)+x%10^(i-1)=x/10^i*10(i-1)+x-x/10^(i-1)*10^(i-1)=x-(x/10^(i-1)-x/10^i)*10^(i-1)x+y=2x-(x/10^(i-1)-x/10^i)*10^(i-1)=n设T=(x/10^(i-1)-x/10^i)2x-T*10^(i-1)=nx=(n+T*10^(i-1))/2x,n,T均为整数且i>1,所以n非偶数直接返回,其他情况则枚举T直到 阅读全文
posted @ 2012-10-06 21:05 tmeteorj 阅读(657) 评论(0) 推荐(0)
POJ 3600
摘要:题意:给一个小矩形,一个大矩形,均是01矩阵,然后问从大矩形中删除一些行一些列是否能得到小矩形。题解:先枚举小矩形由大矩形哪些列组成,然后在判断这些列能否组成小矩形,判断方法为:先将小矩形每一行当做2进制数存入一个一维数组中(长r),在对每一个已经枚举好的大矩形的列也同样按此操作,得到一个长为R的数组,如果第一个数组是第二个数组的子序列,那么就是可行的。这样,枚举列的复杂度O(Choose(C,c)),至多十几万,判断子序列是O(r+R)View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algo 阅读全文
posted @ 2012-10-05 19:07 tmeteorj 阅读(205) 评论(0) 推荐(0)
POJ 3681
摘要:题意:给定n个点,你需要找一个面积最小的矩形将其中的m个点严格的包裹在内。题解:1、尽管求的是严格包裹在内的点,但也可以转化成求非严格,即点可以在边上的,两者对应关系就是x*y=(a+2)*(b+2)。 2、由于n、m都比较小,可以枚举矩形的xmin,xmax。 3、枚举确定xmin和xmax后,实际上矩形的一条边就确定了,要想面积最小,就是使得另一边尽可能的小,即从x坐标满足要求的点中选择m个y坐标最接近的,由于每个枚举都是共用一个数据,所以可以先将n个点按y坐标排序。View Code 1 #include<cstdio> 2 #include<cstring> 3 阅读全文
posted @ 2012-10-05 11:14 tmeteorj 阅读(337) 评论(0) 推荐(0)
POJ 1972
摘要:题意:n个骰子按顺序立成一个栈,求正面向你的那一面的和的最大值。题解:由于规定了顺序,这题也就毫无技术可言了,直接6的枚举第一个骰子的top面其余就确定了。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 int getmax(int a,int b) 6 { 7 for(int i=6;i>=4;i--) 8 if(i!=a&&i!=b) 9 return i;10 }11 int po[100 阅读全文
posted @ 2012-10-04 16:01 tmeteorj 阅读(193) 评论(0) 推荐(0)
POJ 1059
摘要:题意:模拟大富翁游戏,给出骰子会掷出的点数,问最后谁会赢。题解:模拟。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 int ran[1005],id,top; 6 int getnext() 7 { 8 return ran[id++]; 9 }10 int pos[10],to[105],flag[105];11 bool res[105];12 int main()13 {14 int x,y;15 top=0 阅读全文
posted @ 2012-10-04 15:04 tmeteorj 阅读(345) 评论(0) 推荐(0)
POJ 2361&&POJ 3075
摘要:题意:2361:判断三子棋状态是否合法,3075:判断三子棋状态是否合法且是最终状态。题解:别去做3075,那道题题目有误,...XXXOOO明明是不合法的偏偏要说合法,网上AC代码也过不了这样例,实际上这样例第三个'X'走下去的时候就已经结束了!!!!根本不可能有第三个'O',实在想过就扭曲一下题意或者网上贴代码上去吧= =!这是2361的代码。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace st 阅读全文
posted @ 2012-10-03 20:10 tmeteorj 阅读(521) 评论(0) 推荐(0)
POJ 1944
摘要:题意:n个点的环,只能邻接点建边,现在要求m对点相连,求最小边。题解:最后必定是生成的一些链,否则可以把环打开少用一条边。那么可以枚举这个断点在哪,计算取最小值。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<queue> 5 using namespace std; 6 const int N=1005; 7 int to[N],po[10005][2],n,m; 8 int main() 9 {10 while(scanf(&q 阅读全文
posted @ 2012-10-02 15:18 tmeteorj 阅读(391) 评论(0) 推荐(0)
POJ 3332
摘要:题意:检查输入字符串是否是浮点型。题解:模拟= =!View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<cctype> 5 using namespace std; 6 int main() 7 { 8 int T; 9 for(scanf("%d",&T); T; T--)10 {11 char s[1200];12 scanf(" %s",s);13 if(s[0]=='+&# 阅读全文
posted @ 2012-10-02 12:37 tmeteorj 阅读(255) 评论(0) 推荐(0)
POJ 1406
摘要:题意:给定n,确定x*x*x+y*(y+1)*(y+2)/6使得不超过n且最接近n题解:n才十多万,直接打表。View Code 1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 using namespace std; 5 const int N=160000; 6 bool mark[160000]; 7 int main() 8 { 9 memset(mark,false,sizeof(mark));10 for(int x=0;;x++)11 {12 int t=x*x... 阅读全文
posted @ 2012-10-02 12:17 tmeteorj 阅读(208) 评论(0) 推荐(0)
POJ 2810
摘要:题意:字符串处理,分为a,b,c,d四部分,a,c为浮点数,b,d为字符串,除了d以外,其余均无中间空格。然后观察a*100/b,大于1就输出d a b a*100/b%,否则,就在最后一段话后将d输出。题解:同上。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 char ss[1000][1000]; 6 const double eps=1e-8; 7 int main() 8 { 9 char s[1000]; 阅读全文
posted @ 2012-10-01 20:40 tmeteorj 阅读(188) 评论(0) 推荐(0)
POJ 2379
摘要:题意:模拟ACM Ranklist,按AC数,罚时,队伍编号排序。题解:注意2种,A了再交,输出不是按照时间顺序的。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 struct Data 6 { 7 int id,tot,ti; 8 int pr[30]; 9 void init(int _id)10 {11 id=_id;12 tot=ti=0;13 memset(pr... 阅读全文
posted @ 2012-10-01 20:19 tmeteorj 阅读(292) 评论(0) 推荐(0)
POJ 1156
摘要:题意:求矩形中差异值最大不超过c的子矩阵的最大面积。题解:枚举子矩形左右两列,然后记录每行位于这两列之间的最大最小值,建两个单调队列,从上往下一次扫描时,判断差异值是否超过了c,以此来维护队列,再加最优化剪枝。View Code #include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int N=705;int row,col,c;int map[N][N],_min[N],_max[N];//min/max:第i行[a,b]区间最大/小值int Q1[N*2 阅读全文
posted @ 2012-10-01 18:34 tmeteorj 阅读(388) 评论(0) 推荐(0)
POJ 2059
摘要:题意:s*s的正方形上有n个点,求一个圆将它们覆盖但不超出正方形,要求圆的x坐标尽可能小,其次y坐标尽可能小。题解:数据范围太小,直接暴力。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 int po[60][2]; 6 int s,n; 7 bool solve(int x,int y) 8 { 9 int len=min(min(x,y),min(s-x,s-y));10 len=len*len;11 for(i 阅读全文
posted @ 2012-10-01 14:20 tmeteorj 阅读(232) 评论(0) 推荐(0)
POJ 2460
摘要:题意&题解:水,不想说了。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 int po[201000][2]; 6 int main() 7 { 8 int n; 9 while(scanf("%d",&n),n)10 {11 int x,y,m;12 m=(n+1)/2;13 for(int i=1;i<=n;i++)14 scanf("%d%d",&a 阅读全文
posted @ 2012-09-29 11:56 tmeteorj 阅读(176) 评论(0) 推荐(0)
POJ 1509
摘要:题意:将字符串第i位开始的字串提到前面形成A[i],求n个这种串中字典序最小的串的i。题解:1、暴力可以水过。。 2、最小表示法,具体参见IOI2003论文《最小表示法在字符串循环同构问题中的应用》。View Code 1 #include<cstdio> 2 #include<string> 3 #include<algorithm> 4 using namespace std; 5 int main() 6 { 7 int T; 8 for(scanf("%d",&T),getchar();T;T--) 9 {10 char 阅读全文
posted @ 2012-09-25 19:42 tmeteorj 阅读(425) 评论(0) 推荐(0)
POJ 1686
摘要:题意:给出两个含未知数的表达式,判断其是否相等。题解:任意给未知数赋值,看起结果是否相同。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<cctype> 5 using namespace std; 6 const int N=1000; 7 char op[8]= {'+','-','*','/','(',')','\0' 阅读全文
posted @ 2012-09-24 22:29 tmeteorj 阅读(534) 评论(0) 推荐(0)
POJ 2556
摘要:题意:一个点从(300,420)走到(310,420),方向向右,然后遇到A向右转90度再直走10,反之,向左转90度再直走10.题解:同上View Code 1 #include<cstdio> 2 #include<cstring> 3 using namespace std; 4 int dr[][2]={10,0,0,-10,-10,0,0,10}; 5 int main() 6 { 7 char s[250]; 8 while(gets(s)) 9 {10 int x=310,y=420,d=0;11 printf("300 ... 阅读全文
posted @ 2012-09-22 20:04 tmeteorj 阅读(162) 评论(0) 推荐(0)
POJ 2555
摘要:题意:t2摄氏度的冰m2克,扔进t1摄氏度的m1克水中,不考虑外界条件,求最终状态。题解:临界点为0摄氏度,分四种情况讨论,即等于0摄氏度两种,其余两种。先求出将水完全结成冰需要放出的热量和将冰化成水需要吸收的热量,两两比较,判断化冰还是结冰。然后看将水或冰变成0摄氏度的所贡献的热量是否足以使另一个变成自己,如果是,直接热量相减把两者都当成0摄氏度的某样东西加温或者降温即可,否则,也是相减然后看这温度能使多少冰化成水或者水结成冰。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<algorith 阅读全文
posted @ 2012-09-21 18:50 tmeteorj 阅读(331) 评论(0) 推荐(0)
 

上一页 1 2 3 下一页

公告


博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3