摘要: 来源:http://ace.delos.com/usacoprob2?a=5LTgWx8eTT9&S=contact 这题的想法是,把01串转换成二进制,用hash表存储。 为了区分0和00等类似的情况,将所有的子串的高位加个1,例如: 0就用10来存储,00用100存储。 hash表统计子串个数,然后排序输出就是了。 不过如果用string存储输出的数据,直接输出string,总... 阅读全文
posted @ 2013-02-24 10:56 ay27 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 来源:http://poj.org/problem?id=1008这题没什么的,先算出总的天数,再算出另一种日历的表示就是了,没什么技巧可言。需要注意的是一个特殊的数据:4. uayet 259 ,应输出13 ahau 364基本上样例过了,再把上面的特殊数据过了就行了。#include <iostream>#include <cstdio>#include <string>#include <cstring>using namespace std;const char hmonth[19][10] = {"pop", &qu 阅读全文
posted @ 2013-02-24 10:47 ay27 阅读(253) 评论(0) 推荐(0) 编辑
摘要: 哎,这是手贱了,用java写一点都不爽,可能是我不会用java吧T_T。 这题由于数据范围小,水水就过了。 import java.util.*;public class Main { public static void main(String[] args) { Astruct[] s = new Astruct[105]; Scan... 阅读全文
posted @ 2013-02-23 22:06 ay27 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 手痒了用java A了这题。 import java.util.*;public class Main{ public static void main(String[] args) { Scanner in = new Scanner(System.in); int count = 0; int p = in.nextInt(); ... 阅读全文
posted @ 2013-02-23 21:59 ay27 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 用过java的人都知道,java众多的方法能够非常方便的进行数字和字符串之间的转换,而C和C++就麻烦多了。 其实不然,C和 C++也是提供了方便的方法进行转换,不必手写。 1.字符串格式化函数:sscanf和sprintf(stdio.h) 函数原型: int sscanf( const char *, const char *, ...); int sscanf(const ... 阅读全文
posted @ 2013-02-23 19:58 ay27 阅读(322) 评论(0) 推荐(0) 编辑
摘要: 来源:http://poj.org/problem?id=1005 怎么POJ前面的题都那么水= = #include <iostream>#include <cstdio>#include <cmath>using namespace std;#define pi 3.1415926int main(){ int N; cin>>N; for (int Ncase=1... 阅读全文
posted @ 2012-12-12 09:20 ay27 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 来源:http://poj.org/problem?id=1004 唉,还有什么好说的,如此水题都让我等遇上了 #include <cstdio>using namespace std;int main(){ double sum=0.0,x; for (int i=1;i<=12;i++) { scanf("%lf",&x); sum+=x... 阅读全文
posted @ 2012-12-12 08:58 ay27 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 来源:http://poj.org/problem?id=1002&lang=zh-CN 这题用C++的string来写真的很蛋疼,效率低不说,输入输出真的麻烦。由此看出,C++的STL效率不行,不过除非是那种特别卡时的题,一般STL还是不错的。 这是C++的代码: #include <iostream>#include <cstdio>#include <cstring>#inclu... 阅读全文
posted @ 2012-12-11 18:03 ay27 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 来源:http://poj.org/problem?id=1003 这题真的是意外的简单啊,看清楚了数据规模后已经没什么疑问了,水水的过了。 提交的时候还是有点忐忑啊,怎么会有这么水的题= = 我这代码居然用了196K内存,真不知道那些大神怎么可以做到0K秒杀,难道他们不使用变量= = #include <cstdio>using namespace std;int main(){ ... 阅读全文
posted @ 2012-12-11 16:51 ay27 阅读(96) 评论(0) 推荐(0) 编辑
摘要: 来源:http://poj.org/problem?id=1001&lang=zh-CN 这题没什么算法可言,主要是各种情况的处理。 思路:先忽略小数点,算完后输出时在适当的位置输出一个小数点就行了,完全按照高精度乘单精度的方法。至于小数点的输出,因为每乘一次带小数点的数,小数位数相加就是了。 给出几种特殊情况: 25 2 25.0 2 0.1 ... 阅读全文
posted @ 2012-12-11 13:02 ay27 阅读(131) 评论(0) 推荐(0) 编辑