题目链接: D. Bear and Polynomials time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Limak is a little polar bear. He doesn't have many toys and thus he often plays with polynomials. He considers…
Bear and Polynomials 题解: 如果改变一个其中的一个数,那么需要知道的是,前面的数都可以进到当前位来,如果过不来的话,那么就会因为前面有数导致无法变成0. 所以我们将前面的数不断向高位转移,找到第一个不能往上进位的位置, p. 现在只有在0 <= i <= p 的时候才有解. 然后我们从高位到地位转移系数. 然后到0 <= i <= p的地方再check合法性. 注意的是,如果当前系数的绝对值  > 2e9, 那么就是不会再出现合法情况了, 因为不可能再变…
D. Bear and Polynomials 题目连接: http://www.codeforces.com/contest/658/problem/D Description Limak is a little polar bear. He doesn't have many toys and thus he often plays with polynomials. He considers a polynomial valid if its degree is n and its coe…
题目链接: http://codeforces.com/contest/658/problem/D 题意: 给定合法多项式,改变一项的系数,使得P(2)=0,问有多少种方法? 分析: 暴力求和然后依次试一试肯定不行啦~ 仔细想想,多项式和为0,就是说存在某个2i,使得剩下的和等于x∗2i,(其中x 的绝对值小于等于k). 那我们就从最小的开始看.把系数依次向后移. 如果系数ai为偶数,那么ai∗2i=(ai/2)∗2i+1,就令bi=0,否则bi=1,最终所有系数都移到了2n上. 如果某个bi为…
传送门:http://codeforces.com/contest/902/problem/D 本题是一个数学问题——多项式整除. 对于两个整数a.b,求最大公约数gcd(a,b)的辗转相除法的函数如下: int gcd(int a, int b) { ) return a; return gcd(b, a % b); } 一次辗转相除法将数对(a,b)转化成(b,a mod b),直至b=0. 对于多项式A(x),定义deg A(x)为多项式的次数.对于多项式A.B,定义多项式mod运算:若A…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Limak is a little bear who loves to play. Today he is playing by destroying block towers. He built n towers in a row. The i-th tower is made of h…
http://codeforces.com/problemset/problem/735/C 题意:有n个人打锦标赛,淘汰赛制度,即一个人和另一个人打,输的一方出局.问这n个人里面冠军最多能赢多少场,其中一个人和另一个人能打比赛当且仅当这两个人赢的局数相差不超过1. 思路:比赛的时候不会做..直接log2(n)交,果断错了.看题解:因为限制条件两个人能比赛当且仅当他们赢得局数相差不超过1,设F[x]为冠军赢x盘的时候需要的总人数,那么有这样的递推式:F[x] = F[x-1] + F[x-2].…
题目链接: C. Bear and Prime 100 time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output This is an interactive problem. In the output section below you will see the information about flushing the outpu…
题目链接: B. Bear and Finding Criminals //#include <bits/stdc++.h> #include <vector> #include <iostream> #include <queue> #include <cmath> #include <map> #include <cstring> #include <algorithm> #include <cstd…
题目链接: A. Bear and Five Cards //#include <bits/stdc++.h> #include <vector> #include <iostream> #include <queue> #include <cmath> #include <map> #include <cstring> #include <algorithm> #include <cstdio>…