platal cigar

2012年8月3日 #

POJ1844【简单题】

摘要: 一开始的时候没有头绪,只知道前n个数的和为sum=n*(n+1)/2,再深入想的时候找到了规律:如果第i个数标上“-”,则相当于sum-=n*(n+1)/2-2*i,而 sum 和 sum- 奇偶性相同,即 sum 和 num 的奇偶性一定相同。所以如果给出一个偶数 num=sum- ,求出最小的大于等于 num 的偶数 sum=n*(n+1)/2即可 。在这里n值即为所求。代码就很简单了#include<stdio.h>#include<string.h>#include<stdlib.h>int main(){ int num,sum; int i; w 阅读全文

posted @ 2012-08-03 16:34 sappho 阅读(154) 评论(0) 推荐(0)

2012年8月2日 #

POJ1658【简单题】

摘要: 嗯,这道题才有简单题的样子嘛……#include<stdio.h>#include<stdlib.h>#include<string.h>int main(){ int a[10]; int s; int i; for(scanf("%d", &s);s--;) { for(i=1;i<=4;i++) scanf("%d", &a[i]); if(a[2]-a[1] == a[3]-a[2]) a[5] = a[4]+a[3]-a[2]; else a[5] = a[4]*a[4]... 阅读全文

posted @ 2012-08-02 16:58 sappho 阅读(228) 评论(0) 推荐(0)

POJ1517【简单题】

摘要: 这道题乍一看很简单,但是真正要来写的时候还是很容易出错的但是它的本质还是水题,哦呵呵~~#include<stdio.h>#include<stdlib.h>#include<string.h>double ans[10];int i;void inti()//打表{ ans[0] = 1.0; int x; for(i=x=1;i<10;i++,x *= i)//n的阶层 ans[i] = ans[i-1] + 1.0 / (double)x;}int main(){ inti(); printf("n e\n- -----------\n 阅读全文

posted @ 2012-08-02 16:23 sappho 阅读(158) 评论(0) 推荐(0)

POJ1218【简单题】

摘要: 原题链接:http://poj.org/problem?id=1218开关门问题,初始化门(编号1~n)都是关着的,改变状态为开变关、关变开第1遍,全部改变状态第2遍,编码2的倍数的门改变状态第3遍,编码3的倍数的门改变状态……第n遍,编码n的倍数的门改变状态结束后,有多少扇门是开着的----------------方法一:-------------------原始方法,全部遍历一遍,算法复杂度为O(n*n)#include<stdio.h>#include<string.h>#include<stdlib.h>int d[110];int num;int 阅读全文

posted @ 2012-08-02 15:50 sappho 阅读(626) 评论(0) 推荐(0)

POJ3632【简单题】

摘要: 看清本质,说白了就是一个简单的排序问题水题不多说,上代码#include<stdio.h>#include<string.h>#include<stdlib.h>#define SIZE 300int d[SIZE];int cmp(const void *_p, const void *_q){ int *p = (int *)_p; int *q = (int *)_q; return *p-*q;}//升序排列int main(){ int s; int n; int i; scanf("%d", &s); while( s 阅读全文

posted @ 2012-08-02 14:13 sappho 阅读(153) 评论(0) 推荐(0)

POJ3224【简单题】

摘要: Question:将n个学生比赛的结果存在一个n*n的数组中,aij为第i个学生胜出第j个人的比赛场数易错点:Output the number of the student who won the most matches.(not the most number of games won)In the case of a tie, choose the one numbered the smallest。转化成代码应为:if(a[ij]>a[ji] || a[ij] == a[ji]&&i<j) 下面是我理解错误的代码/*错误代码*//*能看出来哪里错了吗*/# 阅读全文

posted @ 2012-08-02 10:30 sappho 阅读(176) 评论(0) 推荐(0)

2012年8月1日 #

POJ2551【简单题】

摘要: 找出一个数的由1组成的最小倍数(10进制)自信满满的写完代码,编译、无误~运行、无误~提交、、、、time limited,555……这是我的代码#include<stdio.h>int main(){ long long sum; int i; int n; while(scanf("%d", &n) != EOF) { sum = 0; for(i=1; ; i++) { sum = sum * 10 + 1; if(sum % n == 0) { ... 阅读全文

posted @ 2012-08-01 09:48 sappho 阅读(148) 评论(0) 推荐(0)

2012年7月31日 #

POJ2370【简单题】

摘要: 投票问题:有K组选民,每组有超过一半人投票有效,最终综合K组投票情况得出投票结果。问最少需要多少人投赞成可使提案通过水题不多说,上代码#include<stdio.h>#include<string.h>#include<stdlib.h>int cmp(const void *_p, const void *_q){ int *p = (int *)_p; int *q = (int *)_q; return *p-*q;}int main(){ int k; int n; int sum; int i; int a[200]; whil... 阅读全文

posted @ 2012-07-31 16:40 sappho 阅读(113) 评论(0) 推荐(0)

2012年7月30日 #

POJ2309【简单题】

摘要: 这是一个比较特殊的树,知道根节点的值,求最小最大值/*这个题比较有趣,可以观察图看出来,一个结点的子节点左边是减去,右边是加上,一个相同的2的次方数,这个数比较有特点,可以模拟计算,也可以利用神奇的x & (-x)*//*普通模拟逐层加减*/ #include<stdio.h>#include<string.h>#include<stdlib.h>int left(int a, int b){return b ? left(a - b, b >> 1) : a;}int right(int a, int b){return b ? rig 阅读全文

posted @ 2012-07-30 16:45 sappho 阅读(256) 评论(0) 推荐(0)

POJ2301【简单题】

摘要: 水题不多说标程#include<stdio.h>#include<string.h>#include<stdlib.h>#define A (a + b) / 2 //先定义,较为简洁#define B (a - b) / 2int main(){ int a, b, T; for(scanf("%d", &T); T --; ) { scanf("%d%d", &a, &b); if((a + b) % 2 || a < b)//不能整出或者和比差小 printf("impos 阅读全文

posted @ 2012-07-30 09:52 sappho 阅读(157) 评论(0) 推荐(0)

导航