CF789B. Masha and geometric depression
/*
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的更多相关文章
- 【cf789B】Masha and geometric depression(分类讨论/暴力)
B. Masha and geometric depression 题意 在黑板上写数列,首项是b,公比是q,超过l时就停止不写.给定m个数,遇到后跳过不写.问一共写多少个数,如果无穷个输出inf. ...
- 【分类讨论】【set】Codeforces Round #407 (Div. 2) B. Masha and geometric depression
模拟一下那个过程,直到绝对值超过l,或者出现循环为止. 如果结束之后,绝对值是超过l的,就输出当前写在黑板上的数量. 如果出现循环,则如果写在黑板上的数量非零,则输出inf(注意!如果陷入的循环是一个 ...
- 【codeforces 789B】Masha and geometric depression
[题目链接]:http://codeforces.com/contest/789/problem/B [题意] 让你一个一个地写出等比数列的每一项 (注意是一个一个地写出); 有m个数字不能写; 且数 ...
- codeforces 789 B. Masha and geometric
链接 B. Masha and geometric depression 题意 给你一个等比数列的首项和公比q,然后给出一个上限l,m个数字,在这个等比数列里,小于l且没有在m个数字里面出现过的可以写 ...
- CodeForces - 789B B. Masha and geometric depression---(水坑 分类讨论)
CodeForces - 789B 当时题意理解的有点偏差,一直wa在了14组.是q等于0的时候,b1的绝对值大于l的时候,当b1的绝对值大于l的时候就应该直接终端掉,不应该管后面的0的. 题意告诉你 ...
- Codeforces Round #407 (Div. 2)
来自FallDream的博客,未经允许,请勿转载,谢谢. ------------------------------------------------------ A.Anastasia and ...
- Codeforces Round #407 div2 题解【ABCDE】
Anastasia and pebbles 题意:你有两种框,每个框可以最多装k重量的物品,但是你每个框不能装不一样的物品.现在地面上有n个物品,问你最少多少次,可以把这n个物品全部装回去. 题解:其 ...
- 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 ...
- 3.26-3.31【cf补题+其他】
计蒜客)翻硬币 //暴力匹配 #include<cstdio> #include<cstring> #define CLR(a, b) memset((a), (b), s ...
随机推荐
- luogu1415 拆分数列
题目大意 给出一列数字,需要你添加任意多个逗号将其拆成若干个严格递增的数.如果有多组解,则输出使得最后一个数最小的同时,字典序最大的解(即先要满足最后一个数最小:如果有多组解,则使得第一个数尽量大:如 ...
- oc65--协议应用1,接口.做数据类型限定
// WifeCondition.h #import <Foundation/Foundation.h> @protocol WifeCondition <NSObject> ...
- oc55--ARC单个对象的内存管理
// Person.h #import <Foundation/Foundation.h> @interface Person : NSObject @end // Person.m #i ...
- JS文件中的中文在网页上显示为乱码解决方法
转自:http://www.pc6.com/infoview/Article_63835.html 如果JS文件中的中文在网页上显示为乱码,不妨采用本文章中的方法来试一试,或许能解决使你很头疼的问题. ...
- Hardwood Species(map)
http://poj.org/problem?id=2418 题意:给定一系列字符串,要求按字典序升序输出每个串,并输出每个串出现的百分比. 用map做的,交c++A了,G++ WA..so sad. ...
- PHP无限级分类实现(递归+非递归)
<?php /** * Created by PhpStorm. * User: qishou * Date: 15-8-2 * Time: 上午12:00 */ //准备数组,代替从数据库中检 ...
- Vue Element-ui table只展开一行
直接上代码了哈~ <template> <div class="app-content"> <div class="table_expand ...
- android 自定义view 前的基础知识
本篇文章是自己自学自定义view前的准备,具体参考资料来自 Android LayoutInflater原理分析,带你一步步深入了解View(一) Android视图绘制流程完全解析,带你一步步深入了 ...
- # --with-http_random_index_module模块
作用: 从目录中随机选取一个随机作为主业 环境 nginx -V 检测是否已经安装了该模块 语法 案例 在/usr/share/nginx下随机创建3个html文件 修改配置文件
- 快速录入快递地址API接口实现
电商.ERP等行业下单环节极其重要,如何提高下单的效率已经成为首要问题.快速下单对于客户来说,为提前发货争取了时间:对于卖家来说,提高了库存周转率及利用率.快速下单的接口实现,需要解决如下几个问题:1 ...