2014年4月1日
摘要: /* 前向星数据结构的实现 2014-4-1 21:36:48*/#include #include #include #include #define MAX 10000using namespace std;int head[MAX]; //存储起点为Vi的第一条边的位置struct NODE{ int from, to, w; //起点,终点,权值};NODE edge[MAX];bool cmp(NODE a, NODE b){ if(a.from == b.from && a.to == b.to) return a.w < b.w; if(a.from == 阅读全文
posted @ 2014-04-01 22:18 长木Qiu 阅读(222) 评论(0) 推荐(0) 编辑
摘要: /* 输入菱形的高度n(只能为奇数),输出图形 2014-4-1 18:38:57*/#include #include int main(){ int n, i, j, cen; char ch[2]; do{ printf("请输入菱形的高度:"); scanf("%d", &n); if(n % 2 == 0){ printf("Sorry, 菱形的高度只能是奇数。请重新来过。\n"); continue; } for(i = 1, cen = n / 2 + 1; i <= n; ++i){ for(j = 1; 阅读全文
posted @ 2014-04-01 18:38 长木Qiu 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 原题链接#include int main(){ int n, t, x; while(scanf("%d", &n) == 1){ x = 0; while(n--){ scanf("%d", &t); x ^= t; } printf("%d\n", x); } return 0;} 阅读全文
posted @ 2014-04-01 11:33 长木Qiu 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 原题链接之前WA了两次,都是由于没考虑到0的情况。样例输入2 湖的个数1 小时数10 1 最初5分钟捕鱼数2 5 每5分钟减少的鱼数2 跑路间隔时间*5 min4410 15 20 170 3 4 31 2 34410 15 50 300 3 4 31 2 30样例输出45, 5Number of fish expected: 31240, 0, 0, 0Number of fish expected: 480115, 10, 50, 35Number of fish expected: 724//关键点:求出在第一个湖耗时最长的,所以如果有多余的时间则尽量都耗在第一个湖边//贪心+枚举#in 阅读全文
posted @ 2014-04-01 11:17 长木Qiu 阅读(165) 评论(0) 推荐(0) 编辑