随笔分类 -  贪心

BOJ 385
摘要:Problem C. VaccineDescriptionOn Christmas Eve, 2029, the unidentified "Apocalypse Virus" spreads andplunges JA into a state of emergency in a chaos known as the "LostChristmas" incident. An international organization known as the GHQintervenes with martial law and restores order 阅读全文

posted @ 2012-03-25 13:30 c语言源码 阅读(276) 评论(0) 推荐(0)

Codeforces Problem 51D - Geometrical problem
摘要:从前三个数中找到公比(最多去掉一个数),检查后面数是否满足等比#include <stdio.h> #include <stdlib.h> #include <math.h> int in[100010]; int min(int a,int b){ return a>b?b:a; } int main(){ int i,j,k,n,p,ans; double d; scanf("%d",&n); for(i=1;i<=n;i++){ scanf("%d",&in[i]); } if(n== 阅读全文

posted @ 2012-01-27 14:01 c语言源码 阅读(148) 评论(0) 推荐(0)

HDU 3573 Buy Sticks 贪心
摘要:很简单一题,见代码#include<stdio.h> #include<stdlib.h> #include<math.h> using namespace std; int min(int a,int b){ return a<b?a:b; } int main(){ int t,T; int a,b,c; scanf("%d",&T); int sum; for(t=1;t<=T;t++){ sum=0; scanf("%d %d %d",&a,&... 阅读全文

posted @ 2012-01-25 22:03 c语言源码 阅读(153) 评论(0) 推荐(0)

HDU 3979 Monster 贪心策略
摘要:听戴牛讲完这题体会了排序不等式在贪心中的作用这个题说的是后很多怪兽同时攻击一个游侠,怪兽有不同的血量和攻击力。游侠有一个攻击力,如果选择攻击怪兽的顺序使得游侠扣血最少贪心构造:对于2只怪兽,A,B;假设当前怪兽总攻击值为V。设怪兽A的攻击力,和被攻击次数(攻击多少次死亡) 为 GA,CA;设怪兽B的攻击力,和被攻击次数(攻击多少次死亡) 为 GB,CB;可知,如果先攻击怪兽A,后攻击怪兽B ,那么游侠的去血量分别为正在杀怪兽A :V *CA ,怪兽A死亡后,正在杀怪兽B :(V-GA) * CB ;杀完两只怪兽的去血总量为 SUM1 = V *CA + (V-GA) * CB; 同理,先攻击怪 阅读全文

posted @ 2012-01-25 21:25 c语言源码 阅读(272) 评论(0) 推荐(0)

导航