自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(26)
  • 收藏
  • 关注

原创 Piotr's Ants UVA - 10881 (思维)

问题链接问题描述:一根长度为L的木棍上有n只蚂蚁,每只蚂蚁要么往左爬,要么往右爬,速度为1,,当两只蚂蚁相撞时,两者同时掉头,给出每只蚂蚁的初始位置和朝向,计算T秒之后每只蚂蚁的位置和朝向。输入:第一行为测试样例的书目  每个测试样例先输入一个n 代表n只蚂蚁    随后n行 每行给出蚂蚁的初始位置和朝向输出:求T秒后各个蚂蚁的位置和朝向

2017-09-23 00:50:02 168

原创 UVa1388 - Graveyard (数学,思维)

题目链接题目描述:在一个周长为10000的圆上等距分布着n个雕塑,现在又有m个新雕塑加入(位置任意放置) 希望所有n+m个雕塑在圆周上均匀分布 这就需要移动其中一些原有的雕塑,要求n个雕塑的移动总距离尽量小。输入:每行为一个n和m输出:最小总距离 精确到1e-4分析:由题目样例我们看到,总有一个雕塑是不需要移动的,事实上我们在推案例的时候也总是先固定一个雕塑,再

2017-09-22 19:14:19 229

原创 UVa 11300 - Spreading the Wealth (数学/递推)

题目链接题目描述:圆桌旁坐着n个人,每个人有一定数目的金币,金币总数能被n整除。每个人可以给相邻的人一些金币,最终使得每个人的金币数目相等,求被转手的金币数量的最小值。输入第一行为整数n接下来n行每行代表第i个人持有的金币数Ai输出:被转手金币的最小值。分析:首先每个人的最终状态我们是能确定的,因为最终金币相等,我们在读取时累计,读取结束

2017-09-22 18:40:54 178

原创 UVa11729 - Commando War (贪心/思维)

题目链接你有n个部下,每个部下需要完成一项任务,第i个部下需要你花费Bi分钟交代任务,然后他会立刻,独立,无间断的执行Ji分钟后完成任务。你需要选择交代任务的顺序,使得所有任务尽早执行完毕(即最后一个执行完的任务应尽早结束)。注意,不能同时给两个部下交代任务,但部下们可以同时执行他们各自的任务。输入:第一行为一个整数n接下来n行每行包括两个正整数,第一个整数为Bi,

2017-09-22 17:18:03 283

原创 UVa-11292 Dragon of Loowater (贪心)

题意:你的王国里一条n个头的恶龙,你希望雇佣一些骑士砍掉他的所有头,村里有m个骑士可以雇佣,一个能力值为x的骑士可以砍掉恶龙一个直径不超过x的头,且需要支付x个金币,如何雇用骑士才能砍掉恶龙的所有头,且需要支付的金币最少?注意,一个骑士只能砍一个头(且不能被雇用两次)输入:第一行为正整数n和m   接下来n行,每行为一个整数,即恶龙每个头的直径  接下来m行,每行为一个整数,即

2017-09-22 16:49:44 209

原创 POJ 3734 Blocks (动态规划) (矩阵幂)

BlocksTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 6976 Accepted: 3370DescriptionPanda has received an assignment of painting a line of blocks. Since

2017-08-12 14:40:16 261

原创 POJ 2104 -- K-th Number (分桶法和平方分割)

K-th NumberTime Limit: 20000MS Memory Limit: 65536KTotal Submissions: 59169 Accepted: 20577Case Time Limit: 2000MSDescriptionYou are working for Macrohard c

2017-08-11 21:44:10 250

原创 POJ 3181 -- Dollar Dayz(动态规划)

Dollar DayzTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 7668 Accepted: 2863DescriptionFarmer John goes to Dollar Days at The Cow Store and discovers

2017-08-11 21:03:35 185

原创 POJ 3046 -- Ant Counting (动态规划)

Ant CountingTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 6037 Accepted: 2246DescriptionBessie was poking around the ant hill one day watching the ant

2017-08-11 20:42:12 160

原创 POJ3276 -- Face The Right Way 反转问题

Face The Right WayTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 5258 Accepted: 2453DescriptionFarmer John has arranged his N (1 ≤ N ≤ 5,000) cows in a

2017-08-06 10:31:40 186

原创 POJ2393 -- Yogurt factory -- 贪心

Yogurt factoryTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 11215 Accepted: 5697DescriptionThe cows have purchased a yogurt factory that makes world-f

2017-08-06 10:00:26 203

原创 POJ2785 -- 4 Values whose Sum is 0(折半枚举)

问题描述: 给定4个数组ABCD从每个数组中选出1个数abcd,使得a+b+c+d=0 每个数组中相同的数组看做不同的情况,因此本题不需要进行剪枝。思路:如果对每个数组的数字进行枚举,那么时间复杂度为n^4,但虽然本题的时长可以为15000ms,也会导致超时。但如果折半来看,枚举2个数组的复杂度为n^2,剩下的2个数组使用二分法来进行计算 那么时间复杂度就为n^2logn 就可以接

2017-08-03 00:48:40 229

原创 POJ3320 -- Jessica's Reading Problem(尺取法)

问题描述: 给定n页书,每页包含一个知识点下面给出n个数 每个数代表第i页描述的知识点求包含所有知识点的连续页数的长度思路: 我们可以这样定义状态: 从当前页开始,满足该条件的最小长度 也就是说我们只需要判断这段书页包含所有的知识点即可而下一个状态只需要减去上一个状态的第一个知识点,再向后推进序列即可(如果去掉的这个知识点是唯一的,那么我们就需要用后面的书页去弥补这个去掉的

2017-08-03 00:39:59 185

原创 POJ3061 -- Subsequence(尺取法)

问题描述:第一行给出测试数据个数第二行给出n和k第三行给出n个数求满足和大于等于k的最短连续子序列长度思路:我们可以这样来考虑:把状态定义为:从第一个数开始,每次求出从第i个数开始的和≥k的连续子段长度而后一个状态只需要减去上一个状态的第一个数,再将序列向后推进,一直加到和≥k即可(用后面的数弥补我们减去的这个数)代码:#include #i

2017-08-03 00:32:44 203

原创 POJ2456 -- Aggressive cows(二分搜索)

问题描述:有n个摊位,坐标分别为x1,x2...xn从中选择c个摊位,使这c个摊位任意两个之间的最小距离最大可以换一个角度思考:选择一个距离x 代表这c个选择的摊位中的最小距离我们要使用二分法搜索的就是满足条件的最大x令C(x):满足条件的最大x 这里需要满足的条件是:由于我们选择的摊位最小距离为x 那么我们必须保证这n个摊位中可以找到c个摊位,使相邻的2个摊位的距离大于等于x

2017-08-03 00:24:56 168

原创 POJ1064 -- Cable master(二分)

问题描述: 给定n条绳子固定分为k段(n,k)在输入文件里 求这几段绳子每段最大分为多长Tips:精度为cm,即两位有效数字 每段至少长为1m代码:#include #include #include #include #include using namespace std;int n,k;double xl[10000 + 5];

2017-08-03 00:08:25 152

原创 Cube Stacking -- 并查集

#include #include #include #include using namespace std;int under[30005]; //下面压的木块数量int wz[30005]; //寻找根节点int sum[30005]; //根节点对应的堆共有多少个木块 void init(){ for(int i =1;i30005;i++)

2017-07-20 15:48:08 138

原创 Bad Hair Day -- 3250poj 单调栈

#include #include using namespace std;stack s;int main(){int n;scanf("%d", &n);long long sum = 0;for(int i =0;i{int now;scanf("%d",&now);if(s.empty()){s.push(now)

2017-07-13 12:42:54 171

原创 Bookshelf 2 -- 动态规划01背包稍作改变

#include #include #include using namespace std;int cow[25];int value[25];int height[1000000];int bad[1000000];int main(){int sum=0;int n,m;int count=0;scanf("%d %d",&n,&m

2017-07-13 10:36:27 268

原创 动态规划 - 01背包问题

#include #include #include using namespace std;int bag[3407][12890];int weight[3407];int value[3407];int main(){memset(bag,0,sizeof(bag));int n ,m;scanf("%d %d",&n,&m);

2017-07-13 09:00:22 246 1

原创 wwdx

#include #include #include using namespace std;int main(){int u , d ,f;int maxMinuate;int nowMinuate=0;int step=0;int road [100010];int len;scanf("%d %d %d %d %d",&

2017-07-12 11:28:07 2254

原创 Master-Mind Hints

#include #include int main(){    int sect[1010];    int game[1010];    int n;    int num[15];    int num1[15];    int xt[15];    int bxt[15];    int countGame=0;    while(1) 

2017-07-12 00:06:40 271

原创 3049-Securing the Barn ====dfs

#include #include #include using namespace std;char pass[20];char yy[10];char fy[30];int sum[30];bool ifyy(char c){return (c=='a' || c== 'e' || c== 'i' || c=='o' || c=='u');}in

2017-07-11 11:25:02 183

原创 Finding Bovine Roots

#include #include const double theE[] ={1,1e-1,1e-2,1e-3,1e-4,1e-5,1e-6,1e-7,1e-8,1e-9};int main(){double t1;double t2;int c,n;scanf("%d",&c);scanf("%d",&n);double flo =

2017-07-11 10:51:21 180

原创 Cow Bowling -- 动态规划的简单递归

#include #include #include#includeusing namespace std;const int MAX = 400;int a[MAX][MAX];int d[MAX][MAX];int n;int solve(int i ,int j){if(d[i][j]>=0)return d[i][j];return d[

2017-07-11 10:12:17 235 1

原创 Election Time

#include #include using namespace std;struct cow{int vote1;int vote2;int id;bool operator {return this->vote1 }}cow[50050];int main(){int n,k;scanf("%d %d",&n,&k)

2017-07-11 09:09:28 178

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除