摘要: 题意:已知每个圆圆心的坐标和半径,求绳的长度。。思路:每个圆心围成的多边形的周长,加上圆的周长。代码:#include <iostream>#include <cmath>#include <iomanip>usingnamespace std;constdouble PI=3.141592;typedef struct{ double x,y;}Point;Point p[103];double a[103];int main(){ int n; double r; cin>>n>>r; cin>>p[0].x>& 阅读全文
posted @ 2011-06-11 12:54 andyidea 阅读(366) 评论(0) 推荐(0) 编辑
摘要: 题意:把所给出的石头分成两堆,使两堆的差最小。思路:这道题可以用01背包写。。也可以直接暴力。。。题上的数据范围决定了dp的效率没有暴力的高。。代码:#include <iostream>#include <algorithm>#include <cstring>#include <cmath>usingnamespace std;int a[23];int sumAll;int def;void DFS(int sum,int i){ if(i<0) return; int temp=abs(sumAll-2*sum); if(def&g 阅读全文
posted @ 2011-06-09 08:51 andyidea 阅读(279) 评论(1) 推荐(1) 编辑
摘要: 题意:求出每个数的平方根,然后倒序输出。保留四位小数。思路:我在Ural的第二道题,我的第一篇ural解题报告,为什么第一道题没有写呢。。。。你们懂的。之所以选择Ural,是因为那上面的题都是原创的,质量很高,有很多国内的童鞋也在那里A题。。。我就是想找一个安静的环境不断的A题,所以就选择了这个oj了。代码:#include <iostream>#include <cstdio>#include <iomanip>#include <cmath>usingnamespace std;double d[1000003];int main(){ // 阅读全文
posted @ 2011-06-06 00:09 andyidea 阅读(687) 评论(0) 推荐(1) 编辑
摘要: 题意:S从1顺时针走,E从n逆时针走。使走到一个位置,他们正好把肉丸给完,而且给的肉丸数量相等。思路:水题,每次让给出的总肉丸数最少的那个人继续给,直到所有人给完。然后判断两个人给的总数是否相同。代码:#include <iostream>#include <cstdio>#include <cstring>using namespace std;int table[33];int main(){ //freopen("input.txt","r",stdin); int n; while(cin>>n,n 阅读全文
posted @ 2011-06-05 11:50 andyidea 阅读(393) 评论(0) 推荐(1) 编辑
摘要: 题意:给出一个区间,求区间内每一个数按规则(奇数取3n+1,偶数取n/2)变换最后变成1的步数,求最大的一个步数。思路:这道题在poj上很快就是水过了,用的是一般的笨方法,后来看到学校的oj也有这道题,就复制粘贴过去,结果WA了,好诡异。然后改了一些细节,TLE了,顿时无语。然后经过各种优化啊,记忆优化啊,有木有!!优化到不能再优化啊,还是TLE啊。没办法了,只能试试其他的方法了。很简单就能想到打表,把题目要求的数据范围内所有的步数都求出来,然后就可以顺利的水了,水过后看见别人做的,用记忆的过了啊,有木有!!我怎么就没过呢~~更多的还是打表~~我的时间有点慢,不解释。。。。顺便说一下,这道题还 阅读全文
posted @ 2011-06-05 10:59 andyidea 阅读(540) 评论(0) 推荐(0) 编辑
摘要: 题意:给出n个点的整数坐标(n<=700),求一条直线,使得在这条直线上的点数最多,输出点数。思路:简单几何题。采用几何中三个点是否在一条直线判定定理。代码:#include <iostream>#include <algorithm>#include <cstdio>using namespace std;typedef struct{ int x,y,count;}Point;Point p[203];double a[203];int main(){ //freopen("input.txt","r",st 阅读全文
posted @ 2011-06-05 02:17 andyidea 阅读(293) 评论(0) 推荐(1) 编辑
摘要: 题意:给出n个点的整数坐标(n<=700),求一条直线,使得在这条直线上的点数最多,输出点数。思路:简单几何题。采用几何中三个点是否在一条直线判定定理。代码:#include <iostream>#include <algorithm>#include <cstdio>using namespace std;typedef struct{ int x,y,count;}Point;Point p[703];double a[703];int main(){ //freopen("input.txt","r",st 阅读全文
posted @ 2011-06-05 02:05 andyidea 阅读(741) 评论(0) 推荐(1) 编辑
摘要: 题意:前16组是被查找组,然后给出每组数据,从16组数据中找出符合公式 D的最小值。。思路:一道水题。遍历每组数据,暴力解之~~~代码:#include <iostream>#include <cmath>#include <cstdio>using namespace std;typedef struct{ int x1,x2,x3;}Color;Color c[16];int fun(Color cm,int i){ return sqrt((cm.x1-c[i].x1)*(cm.x1-c[i].x1)+(cm.x2-c[i].x2)*(cm.x2-c[ 阅读全文
posted @ 2011-06-04 16:54 andyidea 阅读(365) 评论(0) 推荐(0) 编辑
摘要: 题意:输入是第一行两个数字,表示每行的长度和总行数然后是n行字符串求出每行字符串的逆序数,按逆序数从小到大的顺序排列所有的字符串。。什么是逆序数呢,在一个排列中,如果前面的数比后面的大就称为逆序.一个排列中的逆序总数称为逆序数。。例如:给出32145求出它的逆序数,从它的第二个数开始,和它前面的数比较大小,如果是从小到大的顺数,则逆序数为0,如果前面有几个比它大的逆序数就是几。。。方法:对于每个字符串求出逆序数,然后根据逆序数对字符串排序输出。#include <iostream>#include <string>#include <algorithm>#i 阅读全文
posted @ 2011-06-01 10:53 andyidea 阅读(447) 评论(0) 推荐(1) 编辑
摘要: 这道题的大致意思: 圆表示一块面积可扩展的区域,开始时,面积是0,在(0,0)处开始以每年50平方米的速度同样呈半圆扩展,输入一个正整数N,然后输入N对坐标,对于每一对坐标值:求出面积扩展到该点的年数,坐标值单位为米。 理解意思后此题就水很多了。细心的话一次搞定~ #include <iostream>#include <cstdio>#include <cmath>using namespace std;const double PI=3.1415926;int main(){ int n; cin>>n; for(int i=1;i<= 阅读全文
posted @ 2011-05-31 17:51 andyidea 阅读(892) 评论(0) 推荐(1) 编辑