随笔分类 -  Chapter 1. Algorithm Design :: General Problem Solving Techniques

:: Examples
Uva 11384 - Help is needed for Dexter
摘要:/*题意:一个整数n,计算操作次数,把序列(1~n)每次减去一个(1~n)的正整数最终使整个序列都归为0 计算这个最小的操作次数方法:多在本子上画画,递归公式:f(n)=f(n/2)+1;*///AC 1 #include<stdio.h> 2 #include<string.h> 3 //1 ≤ N ≤ 1,000,000,000 int 足够 4 int f(int n) 5 { 6 int c; 7 if(n==1)c=1; 8 else 9 {10 11 c=f(n/2)+1;12 }13 return c;14 }15... 阅读全文

posted @ 2013-03-13 20:18 ACM_Someone like you 阅读(166) 评论(0) 推荐(0) 编辑

Uva 11300 - Spreading the Wealth
摘要:/*题目: 分金币 围着桌子坐n人 每人有一些金币,大家之间可以相互给钱,最终使每个人拥有相同的金币。求最小移动金币个数。考查数学知识:中位数的距离的问题,见“解题手册”P6页其他没有难度,注意找规律。边学边记吧 谁让我笨了!题型可以举一反三。注意。*///AC 1 #include<stdio.h> 2 #include<string.h> 3 //#include<cstdio> 4 #include<algorithm> 5 using namespace std; 6 const int M=1000010; 7 long long c[ 阅读全文

posted @ 2013-03-13 18:56 ACM_Someone like you 阅读(223) 评论(0) 推荐(0) 编辑

11729 Commando War
摘要:Root :: AOAPC I: Beginning Algorithm Contests -- Training Guide (Rujia Liu) :: Chapter 1. Algorithm Design :: General Problem Solving Techniques :: Examples//11729 Commando War/*题意:n个部下,每个部下需要Bi分钟交待任务,让后Ji分钟后完成任务。确定一个顺序,使得最早完成任务。把 说明时间每次累加求和 每组说明和作业时间和 比较大小即可 贪心*///AC#include<stdio.h>#include& 阅读全文

posted @ 2013-02-06 15:12 ACM_Someone like you 阅读(621) 评论(0) 推荐(0) 编辑

uva 11292 - Dragon of Loowater
摘要:/*uva11292-Dragon of Loowatern条恶龙,m个勇士,用勇士来杀恶龙。一个勇士只能杀一个恶龙。而且勇士只能杀直径不超过自己能力值的恶龙。每个勇士需要支付能力值一样的金币。问杀掉所有恶龙需要的最少金币。两个数据从小到大排序后,贪心即可解决对qsort的适用失败了 不知道为啥 所以wa了很多次*///AC#include<stdio.h>#include<string.h>#include<algorithm>#include<iostream>using namespace std;const int M =20010;in 阅读全文

posted @ 2013-01-30 21:25 ACM_Someone like you 阅读(406) 评论(0) 推荐(0) 编辑

导航

< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8
点击右上角即可分享
微信分享提示