上一页 1 ··· 3 4 5 6 7
摘要: 题目: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) 编辑
摘要: 题目:http://hustoj.sinaapp.com/problem.php?id=1816经过计算对比两组数据 注意数据范围是long long#include<stdio.h>int main(){ char ufo[10]; char group[10]; long long ufon=1; long long groupn=1; scanf("%s",ufo); scanf("%s",group); for(int i=0;ufo[i]!='\0';i++) { ufon*=ufo[i]-'A'+1 阅读全文
posted @ 2012-12-23 22:27 Daniel Qiu 阅读(367) 评论(0) 推荐(0) 编辑
摘要: 高中同学问了我一道题,开始以为简单循环就能完成,后来发现原来是道深搜题,一开始还没想出来...问题描述给1到N,N个数,要你从中选取M个出来,请输出每一种的选取情况(根据序列字典序输出,即两个序列比大小,第一位小的小,若相等第二位小的小,若相等第三位小的小……)。 样例输入4 3样例输出1 2 3 1 2 4 1 3 4 2 3 4#include<stdio.h>int ans[10];void dfs(int start,int has,int n,int m){ if(has==m) { for(int i=0;i<m;i++)printf("%d " 阅读全文
posted @ 2012-12-23 21:18 Daniel Qiu 阅读(293) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=2593这题和2479除了输入方式和数据范围不同以外没看出来还有什么不同#include <stdio.h>int dp1[100005],dp2[100005];int arr[100005];int main(){ while (1) { int n; scanf("%d",&n); if(n==0) break; scanf("%d",&arr[0]); dp1[0]=arr[0]; for(int i=1;i<n;i++) ... 阅读全文
posted @ 2012-12-22 18:19 Daniel Qiu 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=2479思路:动态规划 求两段最长子段的和 对每个i来说,求出[0~i-1]的最大子段和以及[i~n-1]的最大子段和,再相加起来,求最大的一个。#include <stdio.h>int dp1[50005],dp2[50005];int arr[50005];int main(){ int T; scanf("%d",&T); while (T--) { int n; scanf("%d",&n); scanf("%d",&arr[0]) 阅读全文
posted @ 2012-12-22 17:18 Daniel Qiu 阅读(144) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7