cf B. Little Dima and Equation】的更多相关文章

http://codeforces.com/contest/460/problem/B import java.util.*; import java.math.*; public class Main { public static void main(String []args) { Scanner cin=new Scanner(System.in); int a,b,c; BigInteger a1="); BigInteger a10="); BigInteger a3=&q…
B. Little Dima and Equation time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following proble…
Codeforces Round #262 (Div. 2) B B - Little Dima and Equation B. Little Dima and Equation time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Dima misbehaved during a math lesson a lot a…
B. Little Dima and Equation time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following proble…
time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all…
http://codeforces.com/problemset/problem/366/D 题意:给出n个点,m条边,a,b,ll,rr分别代表点a,点b相连,点a和点b的区间范围(ll,rr),然后让你选择边相连接使得可以从点1到点n,并且所有被选择的边所共同覆盖的区间范围最大. 4 41 2 1 102 4 3 51 3 1 52 4 2 7 64个点,4条边,现在可以从1--2--4,存在两条路径,(1,10)--(3,5)或者(1,10)——(2,7),要选择这所共同覆盖的区间范围最大…
C. Dima and Salad 题意 有n种水果,第i个水果有一个美味度ai和能量值bi,现在要选择部分水果做沙拉,假如此时选择了m个水果,要保证\(\frac{\sum_{i=1}^ma_i}{\sum_{i=1}^mb_i}==k\),问沙拉最大的美味度是多少? 思路 01背包变形. 对于给出的公式,我们化简一下: \(\sum_{i=1}^ma_i-k*\sum_{i=1}^mb_i==0\) 就变成了把a[i]-k*b[i]作为体积,a[i]作为价值,向容量为0的背包里放,可以取得的…
http://codeforces.com/contest/366/problem/C 题意:给出n个水果的两种属性a属性和b属性,然后挑选苹果,选择的苹果必须要满足这样一个条件:,现在给出n,k,要你求满足这种条件的苹果a属性之和最大,如果找不到,输出-1. 思路:是dp题目,倒是给我提醒比较大.这个题目是可以转化的,转为  所有(aj-k*bj)之和,然后对于任意一个苹果,就是挑与不挑的关系,很明显的背包问题. 对于任意一个苹果,如果选择它,则是dp[v-(aj-k*bj)]+aj,不选择它…
题目链接:http://codeforces.com/problemset/problem/460/B 题目意思:给出a, b, c三个数,要你找出所有在 1 ≤ x ≤ 1e9 范围内满足 x = b·s(x)a + c  这条等式的x的个数,并输出相应的 x 具体是多少. 不看tutorial 都不知道,原来枚举的方向错了,人家是枚举1-81 的情况,我就是枚举1-1e9, = =...直接暴力即可,有个比较要注意的地方,算方程右边的时候有可能超过int,需要用long long 或 __i…
题目地址:http://codeforces.com/contest/460/problem/B 这题乍一看没思路.可是细致分析下会发现,s(x)是一个从1到81的数,不管x是多少.所以能够枚举1到81,这样就转化成了一个一元一次方程.直接求解x就能够了.这时候还要推断x是否在1到10^9之间,而且它的各位数之和是s(x). 这题脑残了两次.. . 第一次是写成了<=10^9..然后发现错误后,就又改了回来. .可是发现10^9是不可能的,. ... 代码例如以下: #include <ios…