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. 一步步教你在Edge浏览器上安装网风笔记

    微软于2022年6月15日正式结束对浏览器"Internet Explorer (IE)"的支持,IE已正式退出历史舞台,取而代之的是目前风头正盛的被微软称为当今最好用的Edge浏 ...

  2. 牛客小白月赛65ABCD(E)

                          比赛链接:牛客小白月赛65_ACM/NOI/CSP/CCPC/ICPC算法编程高难度练习赛_牛客竞赛OJ (nowcoder.com) A:牛牛去购物 题意 ...

  3. 我的第一个自动刷作业脚本(大起大落的selenium经验分享)

    起因 故事的开始是大二的上学期,有一门叫计算机结构(computer organization)的课.新教授这门课的教授在原来的政策上做了一些变动.他引入了一个叫做zybook的作业平台来确保我们能跟 ...

  4. Springcloud源码学习笔记1—— Zuul网关原理

    系列文章目录和关于我 源码基于 spring-cloud-netflix-zuul-2.2.6.RELEASE.jar 需要具备SpringMVC源码功底 推荐学习https://www.cnblog ...

  5. 狂神的springboot课程员工管理系统

    文章目录 springboot-kuangshen 介绍 功能展示 登陆页面 首页 员工管理页面 添加员工信息 删除员工信息 修改员工信息 参考资料 springboot-kuangshen 介绍 狂 ...

  6. 图文并茂学习记录--从零开始进行微信小程序开发+引入Vant Weapp组件

    新建项目 创建页面 让人崩溃的东西来了 经过研究,发现这个图标不可以放在二级,只能一级 项目初始化 引入VANT组件库 文档地址:https://youzan.github.io/vant-weapp ...

  7. Java入门与进阶 P-2.1+P-2.2

    比较运算符 关系运算符(relational operators)也可以称为"比较运算符",用于用来比较判断两个变量或常量的大小.关系运算符是二元运算符,运算结果是 boolean ...

  8. java入门与进阶P-1.7+P-1.8

    赋值 通常在声明变量后,使用赋值语句给变量赋值. 在JAVA中将 "="作为 赋值运算符. 表达式:标识涉及值,变量和操作符的一个运算,他们组合在一起计算出一个新的值.所以赋值语句基本就是计算出一个值 ...

  9. 关于C#中async/await的用法

    一直对c#中async/await的用法模模糊糊,不太清晰,今天写了一下Demo彻底明确一下async/await的用法,以免因为对其不了解而对后期的业务产生影响(比如事务导致的锁表等等). 1. 首 ...

  10. TypeScript 学习笔记 — 函数中的类型(四)

    目录 函数的两种声明方式 可选参数 默认参数 剩余参数 函数的重载 this 的类型 对于函数主要关心的是:函数的入参类型 和 函数的返回值类型 函数的两种声明方式 通过 function 关键字来进 ...