/*
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. ssdb底层实现——ssdb底层是leveldb,leveldb根本上是skiplist(例如为存储多个list items,必然有多个item key,而非暴力string cat),用它来做redis的list和set等,势必在数据结构和算法层面上有诸多不适

    我已经在用ssdb的hash结构,存储了很多数据了,但是我现在的用法正确吗? 我使用hash结构合理吗? 1. ssdb数据库说是类似redis,而且他们都有hash结构,但是他们的命名有点不同,ss ...

  2. poj 1741(树的点分治)

    Tree Give a tree with n vertices,each edge has a length(positive integer less than 1001). Define dis ...

  3. tp的redis驱动

    1.增加分布式支持 使用方法:将文件存放在ThinkPHP框架根目录下的Library\Think\Session\Driver\目录下 config配置参数: //Redis Session配置 ' ...

  4. D - Garden

    Problem description Luba thinks about watering her garden. The garden can be represented as a segmen ...

  5. bug,实现类未找到service

  6. SQLServer2008 字符串函数一览表

    /* 字符串函数 (PS.索引都从1开始计算)*/ /* 指定字符(或字符串)A.字符串B.起始索引.获得A在B中的索引值.*/select Charindex('d','abcdefg',0) -- ...

  7. HTML的display属性将行内元素、块状元素、行内块状元素互相转换以及三者的区别

    1.行内元素 查看演示 (1)设置宽高无效 (2)对margin仅设置左右方向有效,上下无效:padding设置上下左右都有效,即会撑大空间 (3)不会自动进行换行 <html> < ...

  8. android学习-第二讲(修改项目名称和图标,log,过滤器)

    一.在app/src/main/res下有 AndroidManifest.xml打开,打开后如下图1 二.日志工具log log.v()  log.d()  log.i()  log.w()  lo ...

  9. WM消息大全

    消息名 消息值 说明 WM_CREATE 0x0001 应用程序创建一个窗口 WM_DESTROY 0x0002 一个窗口被销毁 WM_MOVE 0x0003 移动一个窗口 WM_SIZE 0x000 ...

  10. MFC 缩放和显示IplImage

    序言:使用OpenCV嵌入MFC的框内,图像大小不能和框大小进行匹配,因此需要缩放,使图像适用于MFC框. 后来找到了一种新的方法,此方案貌似u已经废弃. (1).在MFC中显示图片 void CAv ...