- 博客(171)
- 资源 (3)
- 收藏
- 关注
原创 ACM FAFU - 1406(高精度加法)
题目链接:http://acm.fafu.edu.cn/problem.php?id=1406代码:#include #include char ans[101]={0};int add(char *a1,char *b1){ int len1,len2; int i,j,k=0; char t=0,a2[100],b2[100]; len1=strlen(a1);
2013-12-05 00:33:57
2119
原创 ACM LA3644: X-Plosives(并查集)
在计算机科学中,并查集是一种树型的数据结构,其保持着用于处理一些不相交集合(Disjoint Sets)的合并及查询问题。有一个联合-查找算法(union-find algorithm)定义了两个操作用于此数据结构:Find:确定元素属于哪一个子集。它可以被用来确定两个元素是否属于同一子集。Union:将两个子集合并成同一个集合。因为它支持这两种操作,一个不相交集也常被称为联合-查找数
2013-12-05 00:33:33
1945
原创 acm - cry for no one
再一次回到实验室,距离上次已经四个多月了。诸多业障,三界无安,犹如火灾,众若充满,甚可怖畏,常有生老病死 忧患,如是等火,炽然不息。《成实论》云:“万法刹那生,万法刹那灭,转转相续也”。又经云:“诸行无常是生灭法”。 茹毛饮血,冷暖自知。只有亲自体验过自学,才知道其中的痛苦和艰辛。如果自己当初所走的不是这条极为艰辛、复杂的生活,亦不知何在何为何所得。看着 LK 能去参加省赛,而自己却
2013-12-04 18:38:44
1380
原创 HDU 2048 - 神、上帝以及老天爷
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2048#include #include int main(void){ int i, n; __int64 d[21][2] = {{1,0},{1,0},{2,1},{6,2}}; for (i = 4; i < 21; i++) { d
2013-12-03 17:13:15
824
原创 HDU 2047 - 阿牛的EOF牛肉串
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2047#include #include int main(void){ int i; __int64 d[41][2] = {{0,0}, {1, 2}}; for (i = 2; i < 41; i++) { d[i][0] =
2013-12-03 17:13:06
993
原创 HDU 2046 - 骨牌铺方格
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2046#include #include int main(void){ int i; __int64 d[51] = {1, 1, 2,}; for (i = 3; i < 51; i++) d[i] = d[i-1] + d[i-
2013-12-03 17:12:43
907
原创 HDU 2049 - 不容易系列之(4)——考新郎
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2049#include int main(void){ int i, m, n; __int64 a[21][2] = {{1,0},{1,0},{2,1},{6,2}}; for (i = 4; i < 21; i++) { a[i][0]
2013-12-03 17:12:28
958
原创 HDU 2045 - 不容易系列之(3)—— LELE的RPG难题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2045#include #include int main(void){ int i; __int64 d[51] = {0, 3, 6, 6}; for (i = 4; i < 51; i++) d[i] = d[i-1] + 2*d[i-
2013-12-03 17:12:06
860
原创 HDU 2050 - 折线分割平面
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2050#include int main(void){ int n, i; scanf("%d", &i); while (i-- && scanf("%d", &n)) printf("%d\n", 2*n*n-n+1); return 0;
2013-12-03 17:11:51
936
原创 HDU 2051 - Bitset
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2051#include void TtoB(int n){ if (n) { TtoB(n >> 1); printf("%d", n & 1); }}int main(void){ int n; whil
2013-12-03 17:11:24
976
原创 HDU 2059 - 龟兔赛跑(动态规划)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2059#include int main(void){ int i, j, p[102]; int l, n, c, t; int vr, v1, v2; int len; double dp[102], min, e; while (scanf("%d", &l) !
2013-11-29 15:24:58
1053
原创 HDU 2054 - A == B ?
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2054#include #include void A(char *s){ int len = strlen(s); char *p = s + len - 1; if (strchr(s, '.')) while (*p == '0') *p-- =
2013-11-29 15:08:05
920
原创 HDU 2052 - Picture
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2052#include int main(void){ int w, h, i, j; while (scanf("%d%d", &w, &h) != EOF) { putchar('+'); for (i = 0
2013-11-29 14:58:28
853
原创 HDU 2044 - 一只小蜜蜂...
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2044#include int main(void){ int i, j, n; __int64 d[51] = {1, 1, 2,}; for (i = 3; i < 51; i++) d[i] = d[i-1] + d[i-2];
2013-11-29 14:55:22
879
原创 HDU 2043 - 密码
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2043#include #include int main(void){ int n, a[6]; char c; scanf("%d%*c", &n); while (n--) { a[0] = a[1] = a[2] =
2013-11-29 14:54:50
1262
原创 HDU 2042 - 不容易系列之二
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2042#include #include int main(void){ int n, t; scanf("%d", &t); while(t-- && scanf("%d", &n)) printf("%.0f\n", pow(2, n) + 2); retu
2013-11-29 14:54:40
988
原创 HDU 2041 - 超级楼梯
题目链接:#include int main(void){ int i, n; __int64 m[41] = {0, 1}; for (i = 2; i < 41; i++) m[i] = m[i-1] + m[i-2]; scanf("%d", &n); while (n-- && scanf("%d", &i))
2013-11-29 14:54:30
826
原创 HDU 2040 - 亲和数
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2040#include int A(int n){ int i,sum = 1; for (i = 2; i <= n / 2; i++) if (n % i == 0) sum += i; return sum;}int m
2013-11-29 14:53:44
1031
原创 HDU 2039 - 三角形
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2039#include int main(void){ int n; double a, b, c; scanf("%d", &n); while (n-- && scanf("%lf%lf%lf", &a, &b, &c)) puts(a + b > c && a + c > b
2013-11-29 14:53:41
1001
原创 HDU 2036 - 改革春风吹满地
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2036题目分析:可以利用多边形求面积公式:S = 0.5 * ( (x0*y1-x1*y0) + (x1*y2-x2*y1) + ... + (xn*y0-x0*yn) )其中点(x0, y0), (x1, y1), ... , (xn, yn)为多边形上按逆时针顺序的顶点。
2013-11-29 14:53:28
827
原创 HDU 2032 - 杨辉三角
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2032#include #include int main(void){ int i, j, n; int YanHui[32]; while (scanf("%d", &n) != EOF) { memset(YanHui, 0, size
2013-11-29 14:53:03
1045
原创 HDU 2029 - Palindromes _easy version
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2029#include #include int main(void){ int n; char s[1024]; char t[1024]; scanf("%d%*c", &n); while (n--) { ge
2013-11-29 14:52:53
984
1
原创 HDU 2027 - 统计元音
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2027#include #include int main(void){ int n; int y[5]; char c; scanf("%d%*c", &n); while (n--) { y[0] = y[1] = y[2
2013-11-29 14:52:47
1009
原创 HDU 2026 - 首字母变大写
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2026#include #include int main(void){ char t[128] = {' '}; int i; while (gets(t + 1)) { for (i = 1 ; t[i] ; i++)
2013-11-29 14:52:27
1002
原创 HDU 2025 - 查找最大元素
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2025#include int main(void){ char t[128]; char max; int i; while (gets(t)) { for (max = i = 0 ; t[i] ; i++) {
2013-11-29 14:52:19
944
原创 HDU 2024 - C语言合法标识符
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2024#include#includeint main(){ int n,i,k,l; char a[50]; scanf("%d",&n); getchar(); while(n--)
2013-11-29 14:51:50
1219
原创 HDU 2023 - 求平均成绩
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2023#include #include int main(void){ int n, m; int i, j; int t, d; int s[50]; int c[5]; int sc[50][5]; while (scanf("
2013-11-29 14:51:33
1084
原创 HDU 2030 - 汉字统计
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2030#include #include int main(void){ int n; int count; char c; scanf("%d%*c", &n); while (n--) { count = 0;
2013-11-29 00:07:52
1684
1
原创 HDU 2028 - Lowest Common Multiple Plus (最小公倍数)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2028#includetypedef unsigned long UL;UL gcd(UL u, UL v){ int remainder; remainder = u % v; while(remainder) { u = v;
2013-11-29 00:06:37
1473
原创 FAFU 1072 - 组合(深度优先)
题目链接:http://acm.fafu.edu.cn/problem.php?id=1072组合的话由于数小于等于10,可以用穷举法,不过没有算法味道#include #include int main(void){ int i, n, k, m, sum = 0; int a[10]; int i1, i2, i3, i4, i5, i6, i7, i8, i9, i10;
2013-11-29 00:02:14
1576
原创 HDU 2037 - 今年暑假不AC(贪心 + 动态)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2037贪心算法:#include#includeusing namespace std;struct TV{ int begin; int end;}Tv[105];bool cmp(TV a,TV b){ return a.end < b.end;} int ma
2013-11-28 13:28:38
1089
原创 HDU 2031 - 进制转换
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2031【数制换算的一般方法】 把r进数转换成十进制数,只要把r进制数写成r的各次幂的和的形式。然后按十进制计算结果。(这里r是大于1的自然数)例如: (205.21)8 = 2 × 82 + 0 × 81 + 5 × 80 + 2 × 8-1 + 1 × 8-2把十进制换成r
2013-11-28 01:24:30
1688
原创 HDU 2033 - 人见人爱 A + B
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2033#include int main(void){ int n, i; int t[6]; scanf("%d", &n); while (n--) { for (i = 0 ; i < 6 ; i++)
2013-11-28 01:12:12
2172
原创 HDU 2034 - 人见人爱A-B
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2035你可以直接用C语言去模拟一个集合,然后每读入一个数字,做一次遍历,如果找到就删除。最后才排一次序输出。虽然效率很低,时间复杂度有O(m*n),但对付这一题已经绰绰有余了。也可以0MS 0K AC掉。Code:#include #include int cmp(const
2013-11-28 01:11:51
2364
原创 HDU 2035 - 人见人爱A^B
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2035#include int mi(int n, int m){ return m?(m%2?(mi(n, m/2)*mi(n, m/2)*(n%1000))%1000:(mi(n,m/2)*mi(n,m/2))%1000):1;}int main(void){ in
2013-11-28 01:11:00
2054
原创 HDU 2022 - 海选女主角
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2022#include #include int main(void){ int i, j; int n, m; int x, y; double a, t; while (scanf("%d%d", &n, &m) != EOF)
2013-11-27 00:23:56
1328
原创 HDU 2021 - 发工资咯:)(贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2021#include int main(void){ int n, i, x, sum; while (scanf("%d", &n), n) { sum = 0; for (i = 0 ; i < n ; i++)
2013-11-27 00:23:22
1500
原创 Uva 11995 - I Can Guess the Data Structure! (判断数据类型)
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=229&page=show_problem&problem=3146题目分析:先设定一个结构体数组存储输入的数据,在定义三个函数判断是否为栈,队列,优先队列,再对返回值进行判断。另外,在结构体里面定义友元函数,
2013-11-27 00:19:25
1737
原创 Uva 11991 - Easy Problem from Rujia Liu?(map 查找)
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=229&page=show_problem&problem=3142题目分析:每个询问都搜索一次,猜想超时过不了!于是将其弄成一一映射,用data[v][k]存第k个v的下标,询问的时候O(1)的输出,就不会超
2013-11-27 00:19:02
1501
原创 Uva 11997 - K Smallest Sums(多路归并)
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3148题目分析:代码:#include #include #include using namespace std;const int maxn =
2013-11-27 00:18:30
1350
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅