CodeForces 493 E.Vasya and Polynomial(数学)
来源:互联网 发布:网络棋牌赌博举报没用 编辑:程序博客网 时间:2024/06/05 18:05
Description
有一个系数均非负的多项式函数p(x),已知p(t)=a,p(a)=b,给出t,a,b,问满足条件的p(x)有多少个
Input
输入三个整数t,a,b(1<=t,a,b<=1e18)
Output
输出满足条件的p(x)个数,如果无解则输出0,如果无穷多解则输出INF
Sample Input
2 2 2
Sample Output
2
Solution
有一个系数均非负的多项式函数p(x),已知p(t)=a,p(a)=b,给出t,a,b,问满足条件的p(x)有多少个
Input
输入三个整数t,a,b(1<=t,a,b<=1e18)
Output
输出满足条件的p(x)个数,如果无解则输出0,如果无穷多解则输出INF
Sample Input
2 2 2
Sample Output
2
Solution
#include<cstdio>using namespace std;typedef long long ll;int main(){ ll t,a,b; while(~scanf("%I64d%I64d%I64d",&t,&a,&b)) { if(t==a) { if(a==b)printf("%s\n",a==1?"inf":"2"); else printf("0\n"); } else if(a==b)printf("1\n"); else if(a<t||b<a)printf("0\n"); else { ll p=1,c=0; while(b)c+=(b%a)*p,b/=a,p*=t; if(t==1)printf("%d\n",(c==a||c==1)?1:0); else printf("%d\n",c==a?1:0); } } return 0;}
阅读全文
0 0
- Codeforces 493E Vasya and Polynomial(数学)
- CodeForces 493 E.Vasya and Polynomial(数学)
- CodeForces 493 E.Vasya and Polynomial(数学)
- E - Vasya and Polynomial
- Codeforces Round #281 (Div. 2) E. Vasya and Polynomial 数学 思考题
- Educational Codeforces Round 26 E. Vasya's Function 数学,迭代法
- Codeforces Round #425 (Div. 2) E-Vasya and Shifts (高斯消元)
- Codeforces Round #206 (Div. 2) E. Vasya and Beautiful Arrays
- Codeforces Round #206 (Div. 2) E-Vasya and Beautiful Arrays
- codeforces 493C Vasya and Basketball(二分)
- codeforces #493C# Vasya and Basketball(二分upper_bound+贪心)
- 数学 之 Codeforces 354A - Vasya and Robot
- Vasya and Chess - CodeForces 493 D 博弈
- codeforces 493D Vasya and Chess(博弈?)
- codeforces 493C Vasya and Basketball
- CodeForces 493D Vasya and Chess
- CodeForces 493B Vasya and Wrestling 【模拟】
- CodeForces 493C Vasya and Basketball
- 0912 Oracle函数
- 【cuda】This graphics driver could not find compatible graphics hardware..
- 关于ppp、PPPoE、PPTP、L2TP、IPSec协议的简单认识
- 2017.9.13 找硬币 失败总结
- echart柱形图上面显示内容
- CodeForces 493 E.Vasya and Polynomial(数学)
- Spark连接MongDB
- The Little Schemer读书笔记1
- 最大值以及下标和最小值以及下标js
- 17年9月Java软件工程师面试第四站
- Pyramid match kernel and spatial pyramid matching
- ubuntu的网络设置
- matlab simulink生成HDL代码方法
- 局域网内YUM源端软件包新增