摘要: 题目:http://hustoj.sinaapp.com/problem.php?id=1825制造商从多个原材料提供商获取原材料,使费用最小思路:快排,贪心法#include <stdio.h>#include <stdlib.h>struct milksuply{ int cost; int num;}suply[5005];int cmp(const void *a,const void *b){ return ((milksuply *)a)->cost-((milksuply *)b)->cost;}int main(){ int n,m; sca 阅读全文
posted @ 2012-12-24 16:13 Daniel Qiu 阅读(246) 评论(0) 推荐(0) 编辑
摘要: 题目:http://hustoj.sinaapp.com/problem.php?id=1820输入n个区间取并集,求最长的区间和最长的区间间隔。思路:快排 另外一开始没考虑到如果只有一个区间的情况#include <stdio.h>#include <stdlib.h>struct worktime{ int start; int end;}time[5005];int cmp(const void *a,const void *b){ return ((worktime *)a)->start-((worktime *)b)->start;}int ma 阅读全文
posted @ 2012-12-24 15:45 Daniel Qiu 阅读(331) 评论(0) 推荐(0) 编辑
摘要: 题目:http://hustoj.sinaapp.com/problem.php?id=1819从一串项链某一点向左右分别取珠子,直至颜色不同。思路:珠子的个数最大350,用枚举法;对项链处理可将项链复制后头尾相连存入数组;最后如果统计出的个数超过n,则输出n;#include <stdio.h>char beads[360];int main(){ int n; int ans=0; scanf("%d",&n); scanf("%s",beads); for (int i=0;i<n;i++) { beads[i+n]=be 阅读全文
posted @ 2012-12-24 14:52 Daniel Qiu 阅读(480) 评论(0) 推荐(0) 编辑
摘要: 题目:http://hustoj.sinaapp.com/problem.php?id=1818自1900年以来所有的13日的星期数统计题目的输出貌似有误:七个在一行且相分开的整数,它们代表13日是星期六,星期日,星期一.....星期五的次数.实际情况的输出是从周一到周日依次输出。思路:我的做法比较朴素...把所有的天数遍历一遍。还好数据无误。#include<stdio.h>int ans[7]={0};int date=1,day=1;int main(){ int n; int leap; scanf("%d",&n); for(int i=0;i 阅读全文
posted @ 2012-12-24 00:49 Daniel Qiu 阅读(306) 评论(2) 推荐(0) 编辑
摘要: 题目:http://hustoj.sinaapp.com/problem.php?id=1817几个人互相送钱,问最后每个人收取的比送出的多多少又在数据初始化的问题上搞了半天#include<stdio.h>#include<string.h>struct person{ char name[15]; int money; int give; int get;}f[11];int main(){ int n; scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%s",f[i] 阅读全文
posted @ 2012-12-24 00:16 Daniel Qiu 阅读(574) 评论(0) 推荐(0) 编辑