/*
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. Codeforces Round #277 (Div. 2) D. Valid Sets DP

    D. Valid Sets   As you know, an undirected connected graph with n nodes and n - 1 edges is called a  ...

  2. luogu1064 金明的预算方案

    这道题我就想说一点:审题!附件只有2个!钱是10的整数倍,不是100的整数倍! #include <cstdio> #include <cstring> #include &l ...

  3. 【转】iPhone获取状态栏和导航栏尺寸(宽度和高度)

    原文网址:http://blog.csdn.net/chadeltu/article/details/42708605 iPhone开发当中,有时需要获取状态栏和导航栏高度.宽度信息,方便布局其他控件 ...

  4. 洛谷 P3128 [ USACO15DEC ] 最大流Max Flow —— 树上差分

    题目:https://www.luogu.org/problemnew/show/P3128 倍增求 lca 也写错了活该第一次惨WA. 代码如下: #include<iostream> ...

  5. 实现泛型IEnumerable接口

    用C#实现一个类的IEnumerable接口时有两种方法:1)实现非泛型IEnumerable接口:2)实现泛型IEnumerable(T)接口.如果采用方法1,当集合元素T是值类型时,将涉及到巨多的 ...

  6. LBS(定位)的使用

    一.LBS(定位)的使用 1.使用框架Core Location 2.CLLocationManager (1)CoreLocation中使用CLLocationManager对象来做用户定位 (2) ...

  7. springMVC返回数据的四种方式

    转自:https://blog.csdn.net/itcats_cn/article/details/82119673 springMVC返回数据的四种方式:第一种,通过request.setAttr ...

  8. 浅谈自学Python之路(day3)

    今天的主要内容是: 撒 文件操作 对文件操作的流程: 打开文件,得到文件句柄并赋值给一个变量 通过句柄对文件进行操作 关闭文件 现有文件如下: tonghuazhen 听说白雪公主在逃跑 小红帽在担心 ...

  9. 快速掌握C#7

    1. out 变量(out variables) 以前我们使用out变量必须在使用前进行声明,C# 7.0 给我们提供了一种更简洁的语法 “使用时进行内联声明” .如下所示: var input = ...

  10. B - Helpful Maths

    Problem description Xenia the beginner mathematician is a third year student at elementary school. S ...