100197G Robbers】的更多相关文章

传送门 题目大意 看式子懂题意系列... 分析 自然想到我们先按比例下取整得到一个值,再按每个人这样分配所产生的值从大到小排序,然后将剩下的几个金币自大到小每人分配一个,代码挺好理解的,详见代码. 代码 #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<cctype> #include&…
C. Robbers' watch time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Robbers, who attacked the Gerda's cab, are very successful in covering from the kingdom police. To make the goal of catchi…
Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u   Description Robbers, who attacked the Gerda's cab, are very successful in covering from the kingdom police. To make the goal of catching them even harder, they use their…
Problem UVA1616-Caravan Robbers Accept: 160  Submit: 1156Time Limit: 3000 mSec Problem Description OnceuponatimetherewasagreedyKing who ordered his chief Architect to build a field for royal cricket inside his park. The Kingwassogreedy, thathewouldno…
Problem UVA1616-Caravan Robbers Accept: 96  Submit: 946Time Limit: 3000 mSec Problem Description Long long ago in a far far away land there were two great cities and The Great Caravan Road between them. Many robber gangs “worked” on that road. By an…
A. Robbers' watch time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output Robbers, who attacked the Gerda's cab, are very successful in covering from the kingdom police. To make the goal of ca…
A. Robbers' watch 题目连接: http://www.codeforces.com/contest/685/problem/A Description Robbers, who attacked the Gerda's cab, are very successful in covering from the kingdom police. To make the goal of catching them even harder, they use their own watc…
4484: The Graver Robbers' Chronicles 题目连接: http://acm.scu.edu.cn/soj/problem.action?id=4484 Description One day, Kylin Zhang and Wu Xie are trapped in a graveyard. They find an ancient piece of parchment with a cipher string. After discussion and ana…
C. Robbers' watch time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Robbers, who attacked the Gerda's cab, are very successful in covering from the kingdom police. To make the goal of catchi…
题目链接: C. Robbers' watch time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Robbers, who attacked the Gerda's cab, are very successful in covering from the kingdom police. To make the goal of…
一道贪心题,很久前做的,代码是我以前写的. 题意:有n个抢劫者抢劫了m块金子,然后第i个人平分xi/y块金子,但是会有除不尽的情况而金子不可再分,那么每个人都有一个不满意度fabs(xi / y - ki/m),ki是每个人实际分得的金子数量,要保证所有人的不满意度和最小,问ki应如何分配. 题解:如果可以除尽,ki就是xi * m / y,否则要把不满意度和再多分一块金子的不满意度的差值存起来,按从大到小排序,把多出来的金子数量num给前num个人多分一块. #include <iostrea…
题意:n个抢劫犯分别抢到的金钱是k1, k2, k3,...,一共得到的金钱是m, 但是在分钱的时候是按照x1/y, x2/y, x3/y,....的比例进行分配的!这样的话 一些抢劫犯就会觉得不公平,不公平度为|xi/y - ki/m|(浮点运算), 输出一个序列ki,使得 总的不公平度最小..... 思路:很明显的贪心! 首先按照 [xi/y](取整)的比例将每一个人得到的钱求出来(ni),然后会得到 剩下的钱数, 最后在所有人中找到谁分配的相对比例少了,也就是xi/y*m - ni的最大值…
题目链接:http://codeforces.com/problemset/problem/686/C 给你n和m,问你有多少对(a, b) 满足0<=a <n 且 0 <=b < m 且a的7进制和n-1的7进制位数相同 且b的7进制和m-1的7进制位数相同,还有a和b的7进制上的每位上的数各不相同. 看懂题目,就很简单了,先判断a和b的7进制位数是否超过7,不超过的话就dfs暴力枚举计算就可以了. //#pragma comment(linker, "/STACK:1…
题意: 有m(m<=10^4)个金币分给n(n<=1000)个人,第i个人期望得到所有金币的xi/y,现在给分给每个人一些金币ki使得∑|xi/y-ki/m|最小. Solution: 首先要算出所有人的期望金币,向下取整.如此一来,所有人期望金币的和s一定小于等于m.这个时候我们需要将剩下的m-s个金币分给m-s个人,对于xi/y-ki/m,将其乘上y*m 得到 xi*m-ki*y,n个人中这个值最大的m-s个人就是我们需要分的人. #include <iostream> #in…
二分找到最大长度,最后输出的时候转化成分数,比较有技巧性. AC代码: #include <iostream> #include <cstdio> #include <cstdlib> #include <cctype> #include <cstring> #include <string> #include <sstream> #include <vector> #include <set> #…
大意: 一天n小时, m分钟, 表以7进制显示, 求表显示数字不同的方案数 注意到小时和分钟部分总长不超过7, 可以直接暴力枚举. 关键要特判0, 0的位数要当做1来处理 #include <iostream> #include <algorithm> #include <cstdio> #include <math.h> #include <set> #include <map> #include <queue> #in…
题意:给定 n 个区间,然后把它们变成等长的,并且不相交,问最大长度. 析:首先是二分最大长度,这个地方精度卡的太厉害了,都卡到1e-9了,平时一般的1e-8就行,二分后判断是不是满足不相交,找出最长的.这个题并不难, 就是精度可能控制不好,再就是把小数化成分数时,可能有点麻烦. 代码如下: #include <iostream> #include <cmath> #include <cstdlib> #include <set> #include <…
题目链接:http://codeforces.com/contest/686/problem/C题目大意:给你两个十进制的数n和m,选一个范围在[0,n)的整数a,选一个范围在[0,m)的整数b,要求a的7进制表示和b的7进制表示中的每一位都不重复.其中,a的7进制位数和n-1的7进制位数相同,b的位数和m-1的位数相同.比如,当n=2,m=3时,a和b的其进制表示的所有集合是:a=0, b=1 a=0, b=2 a=1, b=0a=1, b=2 解法:这套题目可以用dfs做.我们开一个数组f[…
x越大越难满足条件,二分,每次贪心的选区间判断是否合法.此题精度要求很高需要用long double,结果要输出分数,那么就枚举一下分母,然后求出分子,在判断一下和原来的数的误差. #include<bits/stdc++.h> using namespace std; typedef long double ld; ; ; struct Seg { int l,r; bool operator < (const Seg& x) const { return l<x.l |…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 二分长度. 显然长度越长.就越不可能. 二分的时候.可以不用管精度. 直接指定一个二分次数的上限就好. 判断长度是否可行.直接用贪心就好. ->贪心(排序区间,尽量让新的区间右端点靠左一点.以便后面的区间有放的地方. 最后得到小数. =>暴力枚举分母i是什么. 然后进行类似一个迭代!?的过程. 如果round(ans*i)/i和ans的差的绝对值更小.则更新分母.分子. [代码] #include <bits/stdc+…
Transportation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2301    Accepted Submission(s): 966 Problem Description There are N cities, and M directed roads connecting them. Now you want to t…
A题:Free Ice Cream 注意要使用LL,避免爆int #include <bits/stdc++.h> #define scan(x,y) scanf("%d%d",&x,&y) using namespace std; typedef long long LL; ; int main() { int n,has,x; while(~scan(n,has)) { LL have=has; ; ;i<n;i++) { cin>>o…
Caravans Time limit: 1.0 secondMemory limit: 64 MB Student Ilya often skips his classes at the university. His friends criticize him for this, but they don't know that Ilya spends this time not watching TV serials or listening to music. He creates a…
SGU200.Cracking RSA------------------------★高斯消元 SGU207.Robbers -------------------------------数论 SGU218.Unstable Systems-------------------★图论.二分 SGU220.LittleBishops-------------------------★★ DP SGU221.BigBishops---------------------------★★ DP SG…
Description There are N cities, and M directed roads connecting them. Now you want to transport K units ofgoods from city 1 to city N. There are many robbers on the road, so you must be very careful. Themore goods you carry, the more dangerous it is.…
Description   Student Ilya often skips his classes at the university. His friends criticize him for this, but they don’t know that Ilya spends this time not watching TV serials or listening to music. He creates a computer game of his dreams. The game…
Problem UVA1616-Caravan Robbers Accept: 531  Submit: 2490Time Limit: 3000 mSec Problem Description Input Input will start with a positive integer, N (3 ≤ N ≤ 500) the number of aliens. In next few lines there will be N distinct integers from 1 to N i…
The Meeting Place Cannot Be Changed CodeForces - 982F Petr is a detective in Braginsk. Somebody stole a huge amount of money from a bank and Petr is to catch him. Somebody told Petr that some luxurious car moves along the roads without stopping. Petr…
Transportation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3045    Accepted Submission(s): 1318 Problem Description There are N cities, and M directed roads connecting them. Now you want to…
NLTK 这是一个处理文本的python库,我们知道文字性的知识可是拥有非常庞大的数据量,故而这属于大数据系列. 本文只是浅尝辄止,目前本人并未涉及这块知识,只是偶尔好奇,才写本文. 从NLTK中的book模块中,载入所有条目 book 模块包含所有数据 from nltk.book import * *** Introductory Examples for the NLTK Book *** Loading text1, ..., text9 and sent1, ..., sent9 Ty…