codeforces 721B B. Passwords(贪心)】的更多相关文章

题目链接: B. Passwords time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vanya is managed to enter his favourite site Codehorses. Vanya uses n distinct passwords for sites at all, however he can…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Vanya is managed to enter his favourite site Codehorses. Vanya uses n distinct passwords for sites at all, however he can't remember which one e…
codeforces 704B - Ant Man 贪心 题意:n个点,每个点有5个值,每次从一个点跳到另一个点,向左跳:abs(b.x-a.x)+a.ll+b.rr 向右跳:abs(b.x-a.x)+a.lr+b.rl,遍历完所有的点,问你最后的花费是多少 思路:每次选一个点的时候,在当前确定的每个点比较一下,选最短的距离. 为什么可以贪心?应为答案唯一,那么路径必定是唯一的,每个点所在的位置也一定是最短的. #include <bits/stdc++.h> using namespace…
CodeForces - 50A Domino piling (贪心+递归) 题意分析 奇数*偶数=偶数,如果两个都为奇数,最小的奇数-1递归求解,知道两个数都为1,返回0. 代码 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <sstream> #include <set> #include <map…
B. Passwords 题目连接: http://codeforces.com/contest/721/problem/B Description Vanya is managed to enter his favourite site Codehorses. Vanya uses n distinct passwords for sites at all, however he can't remember which one exactly he specified during Code…
题意:给定 n 个密码,你要按长度不递减的顺序进行尝试,问你最多和最少试多少次可能找出密码,每尝试 k 次错误的,就要等5秒. 析:我们只要把长度全都统计下来,然后从1开始去找目标长度,最少的就是正好到目标长度,最多的就是把目标长度恰好试完. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <…
题目链接:http://codeforces.com/contest/161/problem/B 题意: 有n个商品和k辆购物车,给出每个商品的价钱c和类别t(1表示凳子,2表示铅笔),如果一辆购物车中有凳子,那么这辆购物车中最便宜的那个物品的价格能减少50%,问你如何放这些物品才能使总价钱最少. 思路: 简单贪心,判断凳子数量是否大于等于k行. #include <bits/stdc++.h> using namespace std; typedef long long LL; typede…
Trading Business 题目连接: http://codeforces.com/problemset/problem/176/A Description To get money for a new aeonic blaster, ranger Qwerty decided to engage in trade for a while. He wants to buy some number of items (or probably not to buy anything at al…
Shopping 题目连接: http://codeforces.com/gym/100803/attachments Description Your friend will enjoy shopping. She will walk through a mall along a straight street, where N individual shops (numbered from 1 to N) are aligned at regular intervals. Each shop…
题目链接:Codeforces 486C Palindrome Transformation 题目大意:给定一个字符串,长度N.指针位置P,问说最少花多少步将字符串变成回文串. 解题思路:事实上仅仅要是对称位置不同样的.那么指针肯定要先移动到这里,改动字符仅仅须要考虑两种方向哪种更优即 可. 然后将全部须要到达的位置跳出来.贪心处理. #include <cstdio> #include <cstring> #include <cstdlib> #include <…