
acm_基础算法
GrimCake
这个作者很懒,什么都没留下…
展开
-
51nod贪心1
输入输入一个字符串S(S的长度 输出由你将1-26分配给不同的字母,使得字符串S的完美度最大,输出这个完美度。输入示例dad输出示例77#include#include#includeusing namespace std;bool cmp(int a,int b){ return a>b;}int原创 2017-02-27 23:28:54 · 260 阅读 · 0 评论 -
UVa11636 Hello World!
贪心水题 注意n=0的情况#include#includeusing namespace std;int main(){ int n; int m,k=1; while(cin>>n){ if(n<0) break; else{ for(int i=0;;i++) if(pow(2,i)>=n){ cout<<"Case "<<k<<": "<<i原创 2017-01-31 23:31:59 · 275 阅读 · 0 评论 -
NYOJ-12 喷水装置2(贪心 区间覆盖)
#include#include#include#include#define MAX 10000+1using namespace std;struct node{ double left,right;};bool cmp_left(struct node a, struct node b){ return a.left<b.left;}int main(){ i原创 2017-03-12 19:37:47 · 421 阅读 · 0 评论 -
NYOJ-14 会场安排问题(贪心 区间覆盖)
#include#include#include#include#define MAX 10000+1#define IN 100000using namespace std;struct node{ int left,right;};bool cmp_right(struct node a, struct node b){ return a.right<b.right;原创 2017-03-12 22:07:08 · 456 阅读 · 0 评论 -
NYOJ-71 独木舟上的旅行(贪心)
先从小到大排序,从前往后扫,在第k个时,如果小于w,就找a[k]之后的数与a[k]和最大且小于w的那一个。之后把那个数设为w+1,这样之后再扫到这个数时就可以直接跳过#include#includeusing namespace std;int main(){ int s; int w, n, a[300+1]; int count; cin>>s; while(s--)原创 2017-03-13 23:32:30 · 396 阅读 · 0 评论 -
NYOJ-91 阶乘之和(贪心)
从大到小贪心#include#includeusing namespace std;long long a[11]; int main(){ long long sum; for(int i=1;i<=10;i++){ sum=1; int k=i; while(k>0){ sum*=k; k--; } a[i]=sum; } int m;原创 2017-03-16 21:21:12 · 339 阅读 · 0 评论 -
NYOJ-106 背包问题(贪心)
把单位价值从大到小贪心#include#includeusing namespace std;struct node{ int v; int w;};int cmp_v(struct node x, struct node y){ return x.v>y.v;}int main(){ int T,s,m; int sum_w,sum_v; node a[11];原创 2017-03-16 22:02:14 · 477 阅读 · 0 评论 -
poj-1328 Radar Installation(贪心+区间选点)
题意:Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the sea side. And any radar installation, locating on t原创 2017-09-16 19:51:47 · 406 阅读 · 0 评论 -
codeforces-102A Clothes(暴力)
链接:http://codeforces.com/problemset/problem/102/A题意:给定n件衣服,每件衣服有价格,有m中配对关系,求最小的价格从中选取三件衣服,使得它们之间能两两配对题解:n很小直接暴力#include<iostream>#include<cstring>#include<map>#include<cstdio&g...原创 2018-04-16 20:55:28 · 343 阅读 · 0 评论