![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
贪心
文章平均质量分 61
CatDsy
一只慵懒的喵
展开
-
Shortest path of the king(贪心)
题目链接 : http://codeforces.com/problemset/problem/3/A题意:king有八个方向可以走,分别为L, R , U, D, LD, LU, RD ,RU 给出king的起点和终点, 问最少需要多少步数,并输出路径,路径可能不唯一。题解: 记起点和终点在横轴上的距离为tx,纵轴上的距离为ty;由tx,ty的正负值得到起点和终点的相对位置。若在横轴与原创 2017-06-21 12:31:04 · 333 阅读 · 0 评论 -
Planning(贪心)
题目链接:[http://codeforces.com/problemset/problem/853/A]分析:记代价为totv,则totv=∑(b[i]−a[i])∗v[i]=∑b[i]∗v[i]−∑a[i]∗v[i]totv=∑(b[i]−a[i])∗v[i]=∑b[i]∗v[i]−∑a[i]∗v[i]totv = \sum (b[i]-a[i]) * v[i] = \sum b[i]...原创 2018-08-11 15:43:31 · 235 阅读 · 0 评论 -
Codeforces Round#433 div 2
A.FractionPetya is a big fan of mathematics, especially its part related to fractions. Recently he learned that a fraction is called proper iff its numerator is smaller than its denominator (a < b) an原创 2017-10-15 20:10:27 · 268 阅读 · 0 评论 -
Change-free (codeforces 767E)
题目链接:[http://codeforces.com/contest/767/problem/E]分析:肯定要尽可能的不去换硬币,才能使代价最小。 如果至第i天,硬币数量不足以支付,那么应该在第1天至第i天中,选择代价最小的一天让收营员找零。可以发现不管是在哪一天获得硬币,硬币数量都是+100,但是每天的代价都不相同,代价的计算公式为:(100−ci%100)∗wi(100−ci%10...原创 2018-08-23 15:35:10 · 647 阅读 · 0 评论