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. 网络监测工具之Zabbix的搭建与测试方法(三) ---Zabbix Agent

    安装客户端 在官方网站下载最新版本zabbix agent v6.2.6,然后默认安装,其中配置服务端的界面如下图: 其他一律默认即可. 启用发现功能 如上图所示,开启发现规则,默认搜索zabbix ...

  2. (8)go-micro微服务Mysql配置

    目录 一 gorm介绍 二 gorm安装 1.1 下载依赖 1.2 使用MySQL驱动 三 CURD操作 1. 查询 1.1 单行查询 1.2 多行查询 2. 插入数据 3. 更新数据 4. 删除数据 ...

  3. Java学习笔记 :2021年12月31日 上午

    Java学习笔记 :2021年12月31日 上午 目录 Java学习笔记 :2021年12月31日 上午 关于计算机语言 1.关于语言的分类 2.小结 关于Java语言的基础语法 1.主方法 2.其他 ...

  4. BBS项目功能编写逻辑思路汇总

    BBS项目功能编写逻辑思路汇总 一.BBS创数据表 二.BBS注册功能 三.BBS登录功能 四.BBS首页搭建 五.BBS修改密码 六.BBS个人站点 七.BBS文章详情 八.BBS导入模块 九.BB ...

  5. Ubuntu 22.04 安装 utools 时的疑难杂症

    Error: libcrypto.so.1.1 原因:libcrypto.so.1.1 该依赖的版本不对,ubuntu 默认是使用的 openssl3 的依赖 这个是 openssl1 的 wget ...

  6. 手把手教你图文并茂windows10安装VMware创建CentOS-7-x86_64运行linux系统

    VMware是什么 VMWare (Virtual Machine ware)可以使你的计算机上同时运行几个系统.例如windows.DOS.LINUX等同时存在,可以将这些系统像程序似的随时切换,并 ...

  7. 学习ASP.NET Core Blazor编程系列二十三——登录(2)

    学习ASP.NET Core Blazor编程系列文章之目录 学习ASP.NET Core Blazor编程系列一--综述 学习ASP.NET Core Blazor编程系列二--第一个Blazor应 ...

  8. saas架构之druid解析表名

    public void preHandle(BoundSql boundSql, RequestEntity requestEntity) { System.out.println("要执行 ...

  9. java执行js脚本

    @Test public void aa() throws NoSuchMethodException { String regular = "function regular(args1) ...

  10. 一次代码重构 JavaScript 图连通性判定

    简介 说重构其实就是整理了代码,第一次自己手写写的很丑,然后看了书上写的,虽然和书上的思路不同但是整理后几乎一样漂亮 效果 整体代码如下 class Node { AdjNodes = new Set ...