C - Functions again CodeForces - 789C
C - Functions again
这道题考查了对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的更多相关文章
- 【codeforces 789C】Functions again
[题目链接]:http://codeforces.com/contest/789/problem/C [题意] 看式子. [题解] 考虑最后的答案区间; 如果那个区间是从奇数位置的数字开始的; 那么奇 ...
- codeforces 407 div1 A题(Functions again)
codeforces 407 div1 A题(Functions again) Something happened in Uzhlyandia again... There are riots on ...
- Codeforces 788A Functions again - 贪心
Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian super ...
- Codeforces E. Bash Plays with Functions(积性函数DP)
链接 codeforces 题解 结论:\(f_0(n)=2^{n的质因子个数}\)= 根据性质可知\(f_0()\)是一个积性函数 对于\(f_{r+1}()\)化一下式子 对于 \[f_{r+1} ...
- 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 ...
- 【codeforces 757E】Bash Plays with Functions
[题目链接]:http://codeforces.com/problemset/problem/757/E [题意] 给你q个询问; 每个询问包含r和n; 让你输出f[r][n]; 这里f[0][n] ...
- [Codeforces 757E] Bash Plays with Functions (数论)
题目链接: http://codeforces.com/contest/757/problem/E?csrf_token=f6c272cce871728ac1c239c34006ae90 题目: 题解 ...
- codeforces 789 C. Functions again(dp求区间和最大)
题目链接:http://codeforces.com/contest/789/problem/C 题意:就是给出一个公式 然后给出一串数求一个区间使得f(l,r)最大. 这题需要一个小小的处理 可以设 ...
- codeforces 788A Functions again
…… 原题: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandia ...
- codeforces C. Functions again
题意:给定了一个公式,让你找到一对(l,r),求解出公式给定的F值. 当时没有想到,我把(-1)^(i-l)看成(-1)^i,然后思路就完全错了.其实这道题是个简单的dp+最长连续子序列. O(n)求 ...
随机推荐
- Mybatis-plus实现数据库的增删改查操作
目录 1.MybatisPlus简介 2.MybatisPlus注解介绍 3.常用方法 4.SpringBoot整合MybatisPlus实现增删改查的一个简单Demo 5.参考资料 1.Mybati ...
- [OpenCV实战]45 基于OpenCV实现图像哈希算法
目前有许多算法来衡量两幅图像的相似性,本文主要介绍在工程领域最常用的图像相似性算法评价算法:图像哈希算法(img hash).图像哈希算法通过获取图像的哈希值并比较两幅图像的哈希值的汉明距离来衡量两幅 ...
- [WPF]限制程序单例运行
代码 System.Threading.Mutex mutex; protected override void OnStartup(StartupEventArgs e) { bool ret; m ...
- 算法学习笔记(8.1): 网络最大流算法 EK, Dinic, ISAP
网络最大流 目录 网络最大流 EK 增广路算法 Dinic ISAP 作者有话说 前置知识以及更多芝士参考下述链接 网络流合集链接:网络流 最大流,值得是在不超过管道(边)容量的情况下从源点到汇点最多 ...
- VMware vSphere vCenter ServerAppliance 7.0安装配置
VMware vSphere vCenter ServerAppliance 7.0安装配置 环境说明: 1.将vCenter ServerAppliance部署在ESXi主机上,安装配置好ESXi主 ...
- 常见非指纹built-in函数
unescape unescape() _函数_可对通过 escape() 编码的字符串进行解码. unescape("abcdefg") 'abcdefg' unescape(& ...
- 后台管理系统带关闭的选项卡(多标签页)功能 适配bootstrap3和4 Bootstrap Hover Dropdown
眼看着是不是很熟悉,其实基本大部门后台管理系统都有这个功能,使用iframe实现展示标签页面. 主要功能:标签页点击,添加标签页,向左滚动标签页,向右滚动标签页,刷新当前标签页,关闭当前标签页,关闭其 ...
- gitlabApi如何获取项目文件夹的commitId
在我们做配置管理系统和gitlab系统集成的时候,有一个常见的场景,就是要获取某个文件的commitId,来记录本次配置文件提交的版本.这个通过gitlabApi很容易实现: GET /proje ...
- .net core 阿里云接口之将指定的OSS文件下载到流
紧接上文,.net core 阿里云接口之获取临时访问凭证_SunshineGGB的博客-CSDN博客 本文继续阿里云接口调用,将指定的OSS文件下载到流. 直接上代码: /// <summar ...
- python3中,len()、isalpha()、isspace()、isdigit()、isalnum()实例
# 实例:使用while循环 import string s1 = input('请输入一个字符串:\n') letters = 0 space = 0 digit = 0 others = 0 i ...