数列1

来源:互联网 发布:Python吧 编辑:程序博客网 时间:2024/06/05 10:46

题目描述

输入

输出

样例输入

0 12000000000 1

样例输出

noyes

提示



题解:

xn=axn-1+b

两边同加b/(a-1).

最终得到xn=(a^n(a+b-1)-b)/(a-1)

再进行讨论求解.



#include <cstdio>#include <iostream>#include <cmath>#include <cstring>#include <algorithm>using namespace std;long long a,b;int main(){    while(scanf("%lld%lld",&a,&b)!=-1)    {        if(a==1000000000)        {            if(!b)printf("no\n");            elseprintf("yes\n");        }        else        {            if(abs(a)<=1000000000 || a+b==1000000000)printf("no\n");            elseprintf("yes\n");        }    }    return0;} 



原创粉丝点击