/*
CF789B. Masha and geometric depression
http://codeforces.com/contest/789/problem/B
水题
各种特判,贼烦
*/
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <iostream>
//#define test
using namespace std;
const int Nmax=1e6+;
long long num[Nmax];
map<long long,int> f;
int main()
{
#ifdef test
#endif
long long a,q,l;
int m;
scanf("%I64d%I64d%I64d%d",&a,&q,&l,&m);
//cin>>a>>q>>l>>m;
for(int i=;i<=m;i++)
{
scanf("%I64d",&num[i]);
f[ num[i] ]=;
}
if(q==1LL)
{
if(abs(a)>abs(l))
{
printf("0\n");
return ;
}
if(f[a]==)
printf("0\n");
else
printf("inf\n");
return ;
}
if(q==-1LL)
{
if(abs(a)>abs(l))
{
printf("0\n");
return ;
}
if(f[a]== && f[-a]==)
{
printf("0\n");
return ;
}
else if(f[a]== && f[-a]==)
{
printf("inf\n");
return ;
}
else
{
printf("inf\n");
return ;
}
}
if(abs(a)>abs(l))
{
printf("0\n");
return ;
}
if(q==0LL)
{
if(f[a]== && f[]==)
{
printf("1\n");
return ;
}
if(f[a]== && f[]==)
{
printf("0\n");
return ;
}
if(f[a]== && f[]==)
{
printf("inf\n");
return ;
}
if(f[a]== && f[]==)
{
printf("inf\n");
return ;
}
return ;
}
if(a==0LL)
{
if(f[a]==)
printf("0\n");
else
printf("inf\n");
return ;
}
//if(abs(a)>abs(l) && f[a]==0)
//{
//printf("0\n");
//return 0;
//}
//if(abs(a*q)>abs(l) && f[a*q]==0)
//{
//printf("1\n");
//return 0;
//}
//else if(abs(a*q)>abs(l))
//{
//printf("0\n");
//return 0;
//}
//if(q==1LL || q==-1LL || q==0LL)
//{
//printf("inf\n");
//return 0;
//}
//if(a==0LL)
//{
//printf("inf\n");
//return 0;
//}
long long ans=0LL;
while()
{
if(abs(a)>abs(l))
break;
//if(ans>=32LL)
//{
//printf("inf\n");
//return 0;
//}
if(f[a]==)
ans++;
a*=q;
}
printf("%I64d\n",ans);
//cout<<ans<<endl;
return ;
}

CF789B. Masha and geometric depression的更多相关文章

  1. 【cf789B】Masha and geometric depression(分类讨论/暴力)

    B. Masha and geometric depression 题意 在黑板上写数列,首项是b,公比是q,超过l时就停止不写.给定m个数,遇到后跳过不写.问一共写多少个数,如果无穷个输出inf. ...

  2. 【分类讨论】【set】Codeforces Round #407 (Div. 2) B. Masha and geometric depression

    模拟一下那个过程,直到绝对值超过l,或者出现循环为止. 如果结束之后,绝对值是超过l的,就输出当前写在黑板上的数量. 如果出现循环,则如果写在黑板上的数量非零,则输出inf(注意!如果陷入的循环是一个 ...

  3. 【codeforces 789B】Masha and geometric depression

    [题目链接]:http://codeforces.com/contest/789/problem/B [题意] 让你一个一个地写出等比数列的每一项 (注意是一个一个地写出); 有m个数字不能写; 且数 ...

  4. codeforces 789 B. Masha and geometric

    链接 B. Masha and geometric depression 题意 给你一个等比数列的首项和公比q,然后给出一个上限l,m个数字,在这个等比数列里,小于l且没有在m个数字里面出现过的可以写 ...

  5. CodeForces - 789B B. Masha and geometric depression---(水坑 分类讨论)

    CodeForces - 789B 当时题意理解的有点偏差,一直wa在了14组.是q等于0的时候,b1的绝对值大于l的时候,当b1的绝对值大于l的时候就应该直接终端掉,不应该管后面的0的. 题意告诉你 ...

  6. Codeforces Round #407 (Div. 2)

    来自FallDream的博客,未经允许,请勿转载,谢谢. ------------------------------------------------------ A.Anastasia and ...

  7. Codeforces Round #407 div2 题解【ABCDE】

    Anastasia and pebbles 题意:你有两种框,每个框可以最多装k重量的物品,但是你每个框不能装不一样的物品.现在地面上有n个物品,问你最少多少次,可以把这n个物品全部装回去. 题解:其 ...

  8. Codeforces Round #407 (Div. 2)A B C 水 暴力 最大子序列和

    A. Anastasia and pebbles time limit per test 1 second memory limit per test 256 megabytes input stan ...

  9. 3.26-3.31【cf补题+其他】

      计蒜客)翻硬币 //暴力匹配 #include<cstdio> #include<cstring> #define CLR(a, b) memset((a), (b), s ...

随机推荐

  1. ubuntu使用ssh连接远程电脑的方法

    目前,大多数linux distributions都预先安装了ssh的客户端,即可以连接别人的电脑.但也有例外的情况,所以,下面先把ssh的客户端与服务端的安装一并讲了吧. ssh客户端及服务端的安装 ...

  2. Android系统升级那些事儿【转】

    本文转载自:http://blog.csdn.net/chenyufei1013/article/details/12705719 版权声明:本文为博主原创文章,未经博主允许不得转载.   目录(?) ...

  3. poj 3498 March of the Penguins(拆点+枚举汇点 最大流)

    March of the Penguins Time Limit: 8000MS   Memory Limit: 65536K Total Submissions: 4873   Accepted: ...

  4. Codeforces--629B--Far Relative’s Problem(模拟)

    Far Relative's Problem Time Limit: 2000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I ...

  5. 【POJ 3740】 Easy Finding

    [题目链接] http://poj.org/problem?id=3740 [算法] Dancing Links算法解精确覆盖问题 详见这篇文章 : https://www.cnblogs.com/g ...

  6. sql将一个表中的数据插入到另一个表中

    sql将一个表中的数据插入到另一个表中 列名不一定要相同,只要你在HH中列出要插入列的列表跟select   from   mm表中的选择的列的列表一一对应就可以了,当然两边的数据类型应该是兼容的.  ...

  7. DMARC 介绍

    DMARC 是什么? DMARC 是 “Domain-based Message Authentication, Reporting & Conformance” 的缩写.它用来检查一封电邮是 ...

  8. JNI学习积累之一 ---- 常用函数大全

    主要资料来源: 百度文库的<JNI常用函数> . 同时对其加以了补充 . 要素  :1. 该函数大全是基于C语言方式的,对于C++方式可以直接转换 ,例如,对于生成一个jstring类型的 ...

  9. android view、viewgroup 事件响应拦截处理机制

    文章中会用到部分网络资源,首先将原作者的链接附上. 但是还是会附上数量较大的关于此部分内容的自己的思考. ----------------------------------------------- ...

  10. mybatis 传map参数

    第一步在你的mapper写上: List<WeixinUserLocationList> findweixinUserLocations(@Param("params" ...