C - Functions again

CodeForces - 789C

这道题考查了对Map的运用

#include<iostream>
#include<cstdio>
#include<map>
#include<cmath>
using namespace std;
typedef long long ll;
map<ll,ll> maps;
ll b1,q,l,m,ans;
int main()
{
cin>>b1>>q>>l>>m;
for(int i=0;i<m;++i)
{
ll p;
scanf("%lld",&p);
maps[p]=1;
}
if(b1==0)
{
if(maps[0]==0) printf("inf");
else printf("0");
return 0;
}
else if(q==0)
{
if(abs(b1)>l)
printf("0");
else if(maps[0]==0) printf("inf");
else if(maps[b1]==0) printf("1");
else printf("0");
return 0;
}
else if(q==1)
{
if(abs(b1)<=l&&maps[b1]==0)
printf("inf");
else
printf("0");
return 0;
}
else if(q==-1)
{
if(abs(b1)>l) printf("0");
else if(!maps[b1]||!maps[-b1]) printf("inf");
else printf("0");
return 0;
}
ll e=b1;
while(abs(e)<=l)
{
if(maps[e]==0) ++ans;
e*=q;
}
printf("%lld",ans);
return 0;
}

C - Functions again CodeForces - 789C的更多相关文章

  1. 【codeforces 789C】Functions again

    [题目链接]:http://codeforces.com/contest/789/problem/C [题意] 看式子. [题解] 考虑最后的答案区间; 如果那个区间是从奇数位置的数字开始的; 那么奇 ...

  2. codeforces 407 div1 A题(Functions again)

    codeforces 407 div1 A题(Functions again) Something happened in Uzhlyandia again... There are riots on ...

  3. Codeforces 788A Functions again - 贪心

    Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian super ...

  4. Codeforces E. Bash Plays with Functions(积性函数DP)

    链接 codeforces 题解 结论:\(f_0(n)=2^{n的质因子个数}\)= 根据性质可知\(f_0()\)是一个积性函数 对于\(f_{r+1}()\)化一下式子 对于 \[f_{r+1} ...

  5. Codeforces 757 E Bash Plays with Functions

    Discription Bash got tired on his journey to become the greatest Pokemon master. So he decides to ta ...

  6. 【codeforces 757E】Bash Plays with Functions

    [题目链接]:http://codeforces.com/problemset/problem/757/E [题意] 给你q个询问; 每个询问包含r和n; 让你输出f[r][n]; 这里f[0][n] ...

  7. [Codeforces 757E] Bash Plays with Functions (数论)

    题目链接: http://codeforces.com/contest/757/problem/E?csrf_token=f6c272cce871728ac1c239c34006ae90 题目: 题解 ...

  8. codeforces 789 C. Functions again(dp求区间和最大)

    题目链接:http://codeforces.com/contest/789/problem/C 题意:就是给出一个公式 然后给出一串数求一个区间使得f(l,r)最大. 这题需要一个小小的处理 可以设 ...

  9. codeforces 788A Functions again

    …… 原题: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandia ...

  10. codeforces C. Functions again

    题意:给定了一个公式,让你找到一对(l,r),求解出公式给定的F值. 当时没有想到,我把(-1)^(i-l)看成(-1)^i,然后思路就完全错了.其实这道题是个简单的dp+最长连续子序列. O(n)求 ...

随机推荐

  1. 3、swagger-ui导出word接口文档

    参考 1.修改swagger2word项目的 application.yml 文件的 swagger.url 为Swagger Json资源的url地址(网址+端口): 例:swagger.url: ...

  2. TiDB上百T数据拆分实践

    背景 提高TiDB可用性,需要把多点已有上百T TiDB集群拆分出2套 挑战 1.现有需要拆分的12套TiDB集群的版本多(4.0.9.5.1.1.5.1.2都有),每个版本拆分方法存在不一样 2.其 ...

  3. 虚假新闻检测(CADM)《Unsupervised Domain Adaptation for COVID-19 Information Service with Contrastive Adversarial Domain Mixup》

    论文信息 论文标题:Unsupervised Domain Adaptation for COVID-19 Information Service with Contrastive Adversari ...

  4. 使用Springboot+redis+Vue实现秒杀的一个Demo

    目录 1.Redis简介 2.实现代码 3.启动步骤 4.使用ab进行并发测试 5.线程安全 6.总结 7.参考资料 1.Redis简介 Redis是一个开源的key-value存储系统. Redis ...

  5. java进阶篇——Stream流编程

    Stream流 函数式接口 1.消费型接口--Consumer @FunctionalInterface public interface Consumer<T> { /** * 对给定的 ...

  6. OpenMP 线程同步 Construct 实现原理以及源码分析(上)

    OpenMP 线程同步 Construct 实现原理以及源码分析(上) 前言 在本篇文章当中主要给大家介绍在 OpenMP 当中使用的一些同步的 construct 的实现原理,如 master, s ...

  7. final关键字用于修饰局部变量-final关键字用于修饰成员变量

    final关键字用于修饰局部变量 局部变量--引用类型 引用类型的局部变量,被final修饰后,只能指向一个对象,地址不能再更改.但是不影响对象内部的成员变量值的 修改,代码如下: public cl ...

  8. Java微服务随机掉线排查思路

    背景 我们的业务共使用11台(阿里云)服务器,使用SpringcloudAlibaba构建微服务集群,共计60个微服务,全部注册在同一个Nacos集群 流量转发路径: nginx->spring ...

  9. 解析sensor_msgs::PointCloud2 ROS点云数据

    1.一个仿真的点云数据 header: seq: 2116 stamp: secs: 1586919439 nsecs: 448866652 frame_id: "LidarSensor1& ...

  10. 学习java Day1

    今天正式开始自学Java,首先在官网安装了最新版的jdk并配置好了环境,随后安装好了eclipse. 使用eclipse运行了一个基础的aa.java文件,并成功打印出hello world 首先我了 ...