上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 17 下一页

hdu 4709 herding 2013 杭电warm up 1004

摘要: 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4709可以证明,三角形是最小的。直接计算三角形面积,取最小的的,Impossible的情况特判就行。计算三角形面积用向量叉积。代码:#include#include#include#include#includeusing namespace std;struct point{ double x; double y;};double area(point A,point B,point C){ double abx=B.x-A.x; double aby=B.y-A.y; d... 阅读全文
posted @ 2013-09-09 14:21 814jingqi的ACM 阅读(89) 评论(0) 推荐(0) 编辑

hdu 3786 寻找直系亲属

摘要: 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=3786题目思路: 我们用p[i]=j 来表示 i 的孩子是j (因为一个parent只有一个孩子,但是一个孩子有两个parent不好形成对应)然后初始化为-1,这样如果遇到父母不清楚的(‘-’) 还是-1,一遇到就break掉,把count还原为0; 如果是家族树上存在的两个结点,那么一定可以通过这样知道他们相隔的代数,于是就可以知道相应的称谓 一堆if-else 比较考基本功代码:#include#include#includeusing namespace std;int p[26];/*int 阅读全文
posted @ 2013-09-08 23:00 814jingqi的ACM 阅读(90) 评论(0) 推荐(0) 编辑

about the plan

摘要: http://www.hhanger.com/ 上面很多srm题解报告啊http://eastsun.iteye.com/blog/225235一个做project euler 的孩纸~10-26 math over 后 好好搞呀~ 阅读全文
posted @ 2013-09-08 22:53 814jingqi的ACM 阅读(73) 评论(0) 推荐(0) 编辑

2013 ACM/ICPC Asia Regional Online —— Warmup1 1005 Balls Rearrangement

摘要: 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4706以前做过的题目: i从0到n-1时,如果一个一个加会很慢,注意到如果mod a的序列 和mod b的序列都处在上升中,那么差距是一样的,这样跳的step就可以大一些~注意下就是如果a,b都是1的话 ,跳步还是没有变动,直接特判为0就行。 还有step*(i%a-i%b)可能会超int 其中一个要用long long 存放代码:#include#includeusing namespace std;int min(int a,int b){ if(a>T; while(T--) { ... 阅读全文
posted @ 2013-09-08 18:15 814jingqi的ACM 阅读(107) 评论(0) 推荐(0) 编辑

poj 1833 给poj跪了 字典排序

摘要: 题目地址:http://poj.org/problem?id=1833直接调用stl里面的next_permutation 只要调用了,不管返回什么,都取了下一个排序。 神奇的是,用c++ac,用g++交tle,跪了 ...代码:#include#include#includeusing namespace std;int p[1024];int main(){ int n,k,m; cin>>m; while(cin>>n>>k) { for(int i=0;i<n;i++) scanf("%d",&p[i]); int 阅读全文
posted @ 2013-09-07 21:41 814jingqi的ACM 阅读(145) 评论(0) 推荐(0) 编辑

hdu 1878 欧拉回路,图的连通性判断

摘要: 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1878判断图上是否有欧拉回路,首先要求是连通图,然后每个顶点的度数必须都为偶数(如果存在两个顶点度数为奇数则是存在欧拉通路)用dfs求连通分支的个数代码:#include#include#include#includeusing namespace std;vector G[1000];bool vis[1000];void dfs(int u){ vis[u]=1; int d=G[u].size(); for(int i=0;i>n>>m) { for(int i... 阅读全文
posted @ 2013-09-05 23:08 814jingqi的ACM 阅读(149) 评论(0) 推荐(0) 编辑

poj 3844 Divisible Subsequences 剩余类,组合计数

摘要: 题目地址:http://poj.org/problem?id=3844思路: a[i]+a[i+1]+...+a[j]=s[j]-s[i]; 于是整除等价于 s[i]===s[j] (mod d); 然后统计出现了多少次 c[n][2]就可以了 。 值得注意的是,有可能50000* (50000-1)/2 要用long long每次进入一个新case 后把p 清零,sum【i】表示前i个数的和, 0=#include#includeusing namespace std;int sum[50005];int p[1000000];int main(){int T;cin>>T;in 阅读全文
posted @ 2013-09-04 11:10 814jingqi的ACM 阅读(115) 评论(0) 推荐(0) 编辑

LA 4609 ,poj 3842 An Industrial Spy

摘要: 题目地址:http://poj.org/problem?id=3842 或者:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2610思路就是暴力求出每一种可能的情况,进行全排列(next_permutation可以去重)然后对每一种排列考虑前面的子串。为了防止一个情况被考虑两次,设置一个占位符b[10000000] 每次新输入数,记得将b清空,然后先转化成int数组,每次翻译成一个int时快一些。这个代码在Uva 阅读全文
posted @ 2013-09-04 01:36 814jingqi的ACM 阅读(88) 评论(0) 推荐(0) 编辑

hdu 4639 2013多校第四场 hehe Fibonacci 数列,组合计数,字符串处理

摘要: 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4639题目思路: 首先我们取出所有he这样的东西,考察连续的k个“he"串,通过找规律+数学归纳法容易证明有f【k】种方式,其中f为Fibonacci数列, 那么再统计这个串中有多少个这样的块就可以了,他们乘起来。代码:#include#includeusing namespace std;;int p[10000];void pre(){ p[1]=1; p[2]=2; for(int i=3;i>T; string s; int index=0; while(T--) ... 阅读全文
posted @ 2013-09-03 22:26 814jingqi的ACM 阅读(101) 评论(0) 推荐(0) 编辑

hdu 4642 Fliping game 翻硬币游戏 抓住特征变量

摘要: 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4642题解思路: 很容易得到,谁先把所有的硬币翻成反面朝上,谁就害得对方没办法继续下去,自己就获胜了,假设进行了K局,使得第一次全部的硬币都反面朝上了。事实上,k在比赛的一开始就确定好了,因为每次操作都会改变最右下角的那个1,0的奇偶性,那么最后一个数一开始是1,k必然是奇数,Alice获胜,一开始是0,k必然是偶数,Bob获胜。 嗯嗯,就这一点巧,感谢ChoiceZ的神YY~代码:#include#include#includeusing namespace std;int main(){ ... 阅读全文
posted @ 2013-09-03 22:03 814jingqi的ACM 阅读(134) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 17 下一页