上一页 1 ··· 9 10 11 12 13 14 下一页
摘要: 让人无语的蛋疼题,我本来是按照求素数那样想求出有多少个因子,再判断其奇偶,但竟然超时。。也不知道他们有多少个case。。。后来一想,不需要求银子个数,只需判是否开方为整数即可判断其奇偶性,然后就过了#include <iostream>#include <cstdio>#include <cmath>using namespace std;long long ans, n, t;int main() { freopen("a.txt", "r", stdin); while(scanf("%lld" 阅读全文
posted @ 2011-05-16 23:09 KOKO's 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 一道小水题,推一下规律即可//============================================================================// Name : 10161.cpp// Author : // Version :// Copyright : Your copyright notice// Description : Hello World in C++, Ansi-style//============================================================================#incl 阅读全文
posted @ 2011-05-16 22:13 KOKO's 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 这个题真2,一下子就看出来思路,暴力就能过,但题目看的不清,A,B是根据Ax+By = 0,我当成一个点比斜率了。。。//============================================================================// Name : 10167.cpp// Author : // Version :// Copyright : Your copyright notice// Description : Hello World in C++, Ansi-style//=================================== 阅读全文
posted @ 2011-05-16 18:10 KOKO's 阅读(283) 评论(0) 推荐(0) 编辑
摘要: 这道题蛋疼了一下午。。。竟然最后是快速幂里面要用long long,真蛋疼,思路还是没错的,就是nlogn的算法//============================================================================// Name : main.cpp// Author : // Version :// Copyright : Your copyright notice// Description : Hello World in C++, Ansi-style//======================================= 阅读全文
posted @ 2011-05-14 01:58 KOKO's 阅读(322) 评论(0) 推荐(0) 编辑
摘要: 这是用eclipse写的第一个程序,还是感觉不太顺手,用多了应该就好了,这道题也没什么说的,看懂题,排个序就好了,直接贴代码//============================================================================// Name : main.cpp// Author : // Version :// Copyright : Your copyright notice// Description : Hello World in C++, Ansi-style//================================= 阅读全文
posted @ 2011-05-13 15:14 KOKO's 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 这个太水了,没什么说的,看懂题意即可#include <iostream>#include <cstdio>#include <cmath>#include <cstring>using namespace std;long long ans;int len;char s[100];int main(){ while(gets(s)&&s[0]!='0') { len = strlen(s); ans = 0; for(int i = 0;i < len;i++) { ans += (pow(2, len-i 阅读全文
posted @ 2011-05-13 01:12 KOKO's 阅读(89) 评论(0) 推荐(0) 编辑
摘要: 一开始没想到什么好的方法,一看数据那么大,感觉得用大数,但又不会写大数。只能看别人怎么做的了。发现一个极好的东西,pow函数可以对浮点型运算,所以只需读入时按照浮点型读入,输出时不输出小数部分即可,完全用不上大数。。。。直接无语了。。。#include <iostream>#include <cmath>#include <cstdio>using namespace std;double n, p;int main(){ while(scanf("%lf%lf", &n, &p)!=EOF) { printf(" 阅读全文
posted @ 2011-05-13 01:11 KOKO's 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 我的思路是将数据按照小的在前存入结构体数组,从前往后看是否配对,后来发现可能会有3个1,2,一个2,1的情况我这样做的结果应该还是正确的,就把第一位和第二位分别存在两个数组里,分别排序,看是否一一对应,这样的话应该就能保证符合题意了。刚才看了看别人的做法,发现竟然二维数组也能过,看来数据不算很强,仅仅把n设到了最大500000,并没有把一一对应的点设这么大还有一个分别把两个数组排序一下竟然也能过。。还有一个说的比较高深,代码也比较长,不过应该是比较靠谱:使用快排预处理,逐个配对,同时使用hash判重,期间要使用二分查找。注意这个二分查找有点特别,先是找到被处理对象的位置,然后再这个区间查找。下 阅读全文
posted @ 2011-05-13 01:10 KOKO's 阅读(228) 评论(0) 推荐(0) 编辑
摘要: 这道题其实说白了就是处理sort的cmp函数,其实就是比较两个连起来的话哪个放前面会更大一些,思路只要想通就很好实现了#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <string>using namespace std;int n;string s[100];bool cmp(string a, string b){ string c, d; c = a+b; d = b+a; return c.compare(d) 阅读全文
posted @ 2011-05-13 01:06 KOKO's 阅读(195) 评论(0) 推荐(0) 编辑
摘要: 真蛋疼,简简单单的一个水题WA了3次,给正方形的相对的两个点坐标,求另两个点坐标,主要是没想清楚,以为fabs就行,fabs求的可能是与所求点轴对称的点。。。#include <iostream>#include <cstdio>#include <cmath>using namespace std;double xx1, xx2, yy1, yy2, xx, yy;int main(){ while(scanf("%lf%lf%lf%lf", &xx1, &yy1, &xx2, &yy2)!=EOF) { 阅读全文
posted @ 2011-05-12 20:21 KOKO's 阅读(186) 评论(0) 推荐(0) 编辑
上一页 1 ··· 9 10 11 12 13 14 下一页