bzoj1673[Usaco2005 Dec]Scales 天平*】的更多相关文章

bzoj1673[Usaco2005 Dec]Scales 天平 题意: n个砝码,每个砝码重量大于前两个砝码质量和,天平承重为c,求天平上最多可放多种的砝码.n≤1000,c≤2^30. 题解: 斐波那契数列到30多项就爆int了,所以本题n其实≤30.故爆搜即可,加个剪枝:当前选的砝码质量和+剩下砝码质量和仍≤ans就返回. 代码: #include <cstdio> #include <cstring> #include <algorithm> #define i…
Description Farmer John has a balance for weighing the cows. He also has a set of N (1 <= N <= 1000) weights with known masses (all of which fit in 31 bits) for use on one side of the balance. He places a cow on one side of the balance and then adds…
http://www.lydsy.com/JudgeOnline/problem.php?id=1673 bzoj翻译过来的c<=230不忍吐槽................................. 这题很奇葩.. 因为这些数像fib数一样递增,所以n<=45...................... ... dfs背包即可... #include <cstdio> #include <cstring> #include <cmath> #in…
题目描述 约翰有一架用来称牛的体重的天平.与之配套的是N(1≤N≤1000)个已知质量的砝码(所有砝码质量的数值都在31位二进制内).每次称牛时,他都把某头奶牛安置在天平的某一边,然后往天平另一边加砝码,直到天平平衡,于是此时砝码的总质量就是牛的质量(约翰不能把砝码放到奶牛的那边,因为奶牛不喜欢称体重,每当约翰把砝码放到她的蹄子底下,她就会尝试把砝码踢到约翰脸上).天平能承受的物体的质量不是无限的,当天平某一边物体的质量大于C(1≤C<2^30)时,天平就会被损坏. 砝码按照它们质量的大小被排成…
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1673 题意: 有n个砝码(n <= 1000),重量为w[i]. 你要从中选择一些砝码,使得这些砝码的总重量最大,但不超过c. w[i]按递增顺序给出,并且保证w[i] >= w[i-1]+w[i-2] (i >= 3). 题解: dfs. 因为w[i] >= w[i-1]+w[i-2],所以其实n最大只有45左右(类似斐波那契数列). 优化: (1)启发式:优先选砝码(不…
真是神奇 根据斐波那契数列,这个a[i]<=c的最大的i<=45,所以直接搜索即可 #include<iostream> #include<cstdio> using namespace std; const int N=1005; int n; long long a[N],b[N],tot,s[N],c,ans; void dfs(int w,long long v) { if(v+s[w-1]<=c) { ans=max(ans,v+s[w-1]); ret…
[BZOJ1672][Usaco2005 Dec]Cleaning Shifts Description Farmer John's cows, pampered since birth, have reached new heights of fastidiousness. They now require their barn to be immaculate. Farmer John, the most obliging of farmers, has no choice but hire…
[Usaco2005 Dec]Knights of Ni 骑士 Description  贝茜遇到了一件很麻烦的事:她无意中闯入了森林里的一座城堡,如果她想回家,就必须穿过这片由骑士们守护着的森林.为了能安全地离开,贝茜不得不按照骑士们的要求,在森林寻找一种特殊的灌木并带一棵给他们.当然,贝茜想早点离开这可怕的森林,于是她必须尽快完成骑士们给的任务,贝茜随身带着这片森林的地图,地图上的森林被放入了直角坐标系,并按x,y轴上的单位长度划分成了W×H(1≤W,H≤1000)块,贝茜在地图上查出了她自…
1672: [Usaco2005 Dec]Cleaning Shifts 清理牛棚 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 414  Solved: 191[Submit][Status] Description Farmer John's cows, pampered since birth, have reached new heights of fastidiousness. They now require their barn to…
1671: [Usaco2005 Dec]Knights of Ni Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 175  Solved: 107[Submit][Status][Discuss] Description Bessie is in Camelot and has encountered a sticky situation: she needs to pass through the forest that is guarded b…