【CF493E】【数学】Vasya and Polynomial
Vasya is studying in the last class of school and soon he will take exams. He decided to study polynomials. Polynomial is a function P(x) = a0 + a1x1 + ... + anxn. Numbers ai are called coefficients of a polynomial, non-negative integer n is called adegree of a polynomial.
Vasya has made a bet with his friends that he can solve any problem with polynomials. They suggested him the problem: "Determine how many polynomials P(x) exist with integer non-negative coefficients so that
, and
, where
and b are given positive integers"?
Vasya does not like losing bets, but he has no idea how to solve this task, so please help him to solve the problem.
The input contains three integer positive numbers
no greater than 1018.
If there is an infinite number of such polynomials, then print "inf" without quotes, otherwise print the reminder of an answer modulo 109 + 7.
|
1
|
2 2 2
|
|
1
|
2
|
|
1
|
2 3 3
|
|
1
|
1
|
【分析】
题意:给出三个正整数t,a,b。
问有多少个形如P(x) = a0 + a1 * x + a2 * (x ^ 2) + ....+an * (x ^ n) {ai >= 0 | 0<= i <=n} 的多项式满足P(t) = a,且P(a) = b。注意n未给出。
有意思的一道题。
答案只有三种情况:
1、t = a = b = 1,Ans = INF。显然,n可以取到任意大。
2、t = a = b > 1,Ans = 2。也比较显然,既P(t) = t,仅在 n = 0, a0 = t和 n = 1, a1 = 1, a0 = 0的时候成立,n再大 $t^n$ 就会导致答案大于t了。
3、其他情况下最多一组解。
证明:
首先由P(t) = a 易知 多项式sum{ai | 0<= i <=n} <= a,且仅在t = 1的时候取等号。
①t > 1
假设存在一个多项式P(a) = a0 + a1 * a + a2 * (a ^ 2) +.... +an * (a ^ n) = b,我们尝试将其中任意一项 (a ^ k)的系数 ak 减 1 (k >= 1 且 ak > 0)。
整体的值减少了(a ^ k), 将a ^ k 化为 (a ^ k1) * (a ^ k2),(k1+k2 = k 且 k1 <= k2),把a ^ k1当做系数,将会使整个多项式的系数大于等于a(系数增加了至少a - 1),因此不满足条件。
所以可知,如果存在一个多项式P(a)满足条件,一定不存在其他的多项式满足条件,即最多只存在一个多项式符合条件。
想要得到这个多项式也很简单,即相当于对b进行进制转换,变成a进制,然后再将t带入验证即可。
②t = 1
P(1) = a0 + a1 + a2 + .. an = a,P(a) = a0 + a1 * a + a2 * (a ^ 2) + .. an * (a ^ n) = b;
看到系数和已经被确定了为a了,接下来证明跟上面一样的...
代码没写....
【CF493E】【数学】Vasya and Polynomial的更多相关文章
- cf493E Vasya and Polynomial
Vasya is studying in the last class of school and soon he will take exams. He decided to study polyn ...
- Codeforces Codeforces Round #319 (Div. 2) C. Vasya and Petya's Game 数学
C. Vasya and Petya's Game Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/ ...
- Codeforces Round #319 (Div. 2) C. Vasya and Petya's Game 数学
C. Vasya and Petya's Game time limit per test 1 second memory limit per test 256 megabytes input sta ...
- 数学 - Codeforces Round #319 (Div. 1)A. Vasya and Petya's Game
Vasya and Petya's Game Problem's Link Mean: 给定一个n,系统随机选定了一个数x,(1<=x<=n). 你可以询问系统x是否能被y整除,系统会回答 ...
- poj 2126 Factoring a Polynomial 数学多项式分解
题意: 给一个多项式,求它在实数域内的可分解性. 分析: 代数基本定理. 代码: //poj 2126 //sep9 #include <iostream> using namespace ...
- CodeForces 577C Vasya and Petya's Game 数学
题意就是给你一个1到n的范围 你每次可以问这个数是否可以被某一个数整除 问你要猜多少数才能确定这个数…… 一开始一点思路也没有 后来查了一下才知道 每个数都可以分为几个质数的整数次幂相乘得到…… #i ...
- Codeforces Round #512 (Div. 2) D.Vasya and Triangle 数学
题面 题意:给你n,m,k,在你在(0,0)到(n,m)的矩形内,选3个格点(x,y都是整数),使得三角形面积为n*m/k,不能找到则输出-1 题解:由毕克定理知道,格点多边形的面积必为1/2的整数倍 ...
- Polynomial Library in OpenCascade
Polynomial Library in OpenCascade eryar@163.com 摘要Abstract:分析幂基曲线即多项式曲线在OpenCascade中的计算方法,以及利用OpenSc ...
- 一些对数学领域及数学研究的个人看法(转载自博士论坛wcboy)
转自:http://www.math.org.cn/forum.php?mod=viewthread&tid=14819&extra=&page=1 原作者: wcboy 现在 ...
随机推荐
- HW1.5
public class Solution { public static void main(String[] args) { System.out.println("(9.5 * 4.5 ...
- POJ1365 - Prime Land(质因数分解)
题目大意 给定一个数的质因子表达式,要求你计算机它的值,并减一,再对这个值进行质因数分解,输出表达式 题解 预处理一下,线性筛法筛下素数,然后求出值来之后再用筛选出的素数去分解....其实主要就是字符 ...
- Android模拟器如何加载本机地址及访问本机服务器
首先获取本机ip地址: 在cmd 命令窗口中输入 ipconfig 查看本地电脑ip地址如下: 获取服务器上的Json数据,并返回结果,部分代码如下: 注:StreamUtils是自定义的一个工具类, ...
- asp.net Mvc+bootstarp+esayUI+EF 框架(一)
"框架" 这两个字从通俗的意义来讲就是提高复用性,解耦类之间的关系和方便开发人员开发. 使用的技术也是大家基本现在都用过的,而这个系类我所要讲的内容是什么呢? 框架的基本 ...
- IOS tableView 自定义cell 多行时 文字重复现象
今天写了一个demo,有一个问题,有很多cell,但是超过一页后往下翻,发现文字有重叠现象, cell用的是重用机制,按说不会这样,最终解决的方案: 勾选这个,clears graphics cont ...
- android 文件读取(assets、raw)
需要注意的是,来自Resources和Assets 中的文件只可以读取而不能进行写的操作. assets文件夹里面的文件都是保持原始的文件格式,需要用AssetManager以字节流的形式读取文件. ...
- HDU 3259 Wormholes
题意:就是给你一个n,m,t n代表有多少个点.m代表有多少个双向的边 t代表的是虫洞.如今要你判读是否还能够穿越到过去的点 虫洞的意思是给你的边是单向的,而且是负权值(输入的时候是正数) 思路 ...
- textarea文本域宽度和高度(width、height)自己主动适应变化处理
文章来源:http://www.cnblogs.com/jice/archive/2011/08/07/2130069.html <HTML> <HEAD> <TITLE ...
- textLayout_1.0.0.595.swz
使用ai制作的矢量素材,导出到flash里面.生成swf时.有的时候会多一个textLayout_1.0.0.595.swz的文件. 这会导致导出的swf无法加载使用.会显示不出来. 解决办法是: 检 ...
- tarball文件安装的大概流程
./configure这个步骤就是在创建 Makefile 这个文件罗!通常程序开发者会写一支 scripts 来检查你的 Linux 系统.相关的软件属性等等,这个步骤相当的重要, 因为未来你的安装 ...