摘要: 排序View Code #include <iostream>#include <cstdlib>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;#define maxn 1005#define maxl 55struct Word{ char name[maxl];}word[maxn];int word_num, int_num;bool is_word[maxn];int number[maxn];void uni_case(c 阅读全文
posted @ 2013-01-16 21:11 undefined2024 阅读(181) 评论(0) 推荐(0)
摘要: 题意:一叠卡片,用一种摆法,要求每张卡片短边与桌檐平行,并让他们超出桌檐尽量多,问能超出桌檐多少。分析:对于n张卡片的最佳摆法,我们只需要在n-1张卡片的摆法下面加一张边缘与桌檐重合的卡片,并将所有卡片一起向桌檐外移动。对于一种最佳摆法,其中心一定在桌檐上,所以一定符合杠杆原理,支点是桌檐。那么对于n张卡片的情况,我们假设第n张向外移动了x,那么前n-1张的重心就在桌檐外x,因为他们的重心在n-1张卡片时原本在桌檐上。第n张卡片的重心在桌檐内0.5-x处,那么我们可以列出杠杆平衡方程:(0.5-x)*1=x*(n-1)解得:x=1/(2n)。那么我们所要的答案也就是1/2+1/(2× 阅读全文
posted @ 2013-01-16 09:34 undefined2024 阅读(492) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdlib>#include <cstdio>#include <cstring>using namespace std;#define maxn 10001bool is_self[maxn];int generate(int a){ int ret = a; while (a) { ret += a % 10; a /= 10; } return ret;}int main(){ for (int i = 1; i < maxn; i++)... 阅读全文
posted @ 2013-01-16 08:36 undefined2024 阅读(225) 评论(0) 推荐(0)
摘要: 枚举View Code #include<iostream>#include<algorithm>using namespace std;struct point{ char ss; int x, y;};struct direction{ char ul, ur, lr, ll;};direction dir[100];point p[30];int sum;int cmp(point a, point b){ if (a.x != b.x) return a.x < b.x; else return a.y < b.y;}int c... 阅读全文
posted @ 2013-01-16 08:22 undefined2024 阅读(196) 评论(0) 推荐(0)