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. 线性方程组的直接解法——Gauss消去法

    考虑线性方程组 \[\mathrm{A}x=\mathrm{b} \] 其中,\(\mathrm{A}=(a_{ij})_{n\times n}\),\(\mathrm{b}=[b_1,b_2,\cd ...

  2. 1.5万字总结 Redis 常见面试题&知识点

    以下内容来源于于我开源的 JavaGuide (Java学习&&面试指南,Github 130k star,370人共同参与爱完善), 万字总结,质量有保障! 这篇文章最早写于2019 ...

  3. 根号分治简单笔记 | P3396 哈希冲突

    简要题意 你需要维护一个长度为 \(n\) 的序列 \(v\),支持: A x y 求整个序列中,所有模 \(x\) 为 \(y\) 的下标的元素的值,即: \[\sum_{i=0}^{\lfloor ...

  4. P5687 [CSP-S2019 江西] 网格图

    题面 给定一个 \(n\times m\) 的网格图,行从 \(1\sim n\) 编号,列从 \(1\sim m\) 编号,每个点可用它所在的行编号 \(r\) 与所在的列编号 \(c\) 表示为 ...

  5. java入门与进阶-P1.5+P1.6

    输入 Scanner输入语句介绍 java.util.Scanner 是 Java5 的新特征,我们可以通过 Scanner 类来获取用户的输入. 下面是创建 Scanner 对象的基本语法: Sca ...

  6. 结构型模式 - 代理模式Proxy

    学习而来,代码是自己敲的.也有些自己的理解在里边,有问题希望大家指出. 代理模式的定义与特点         代理模式的定义:由于某些原因需要给某对象提供一个代理以控制对该对象的访问.这时,访问对象不 ...

  7. 11月15日内容总结——软件开发架构、网络编程介绍和OSI七层协议介绍

    目录 一.软件开发架构 1.什么是软件开发架构 2.软件开发架构 架构方式一:c/s架构 架构方式二:b/s架构 架构优劣势 二.架构总结 三.网络编程前戏 1.什么是网络编程 2.学习网络编程的目的 ...

  8. 城市路(Dijkstra)

    这道题目需要用到 Dijkstra plus 版(堆优化) 模板还是一样就是有几个点值得注意 1.这里用的是优先队列,原版需要搜出最小,并且没用过的点,省时间就剩在这里用小根堆就可以完美解决这个问题. ...

  9. T02 ExtractSubject 项目开发总结

    公纵号: 皮豪 博客:www.kbug.cn 邮箱:pphboy@qq.com 前言 看来已经是一种习惯,每次寒假都会开发一个项目出来.本次项目使用的是Qt GUI,语言是C++.不得不说,在业务上写 ...

  10. Codeforces Round #849 (Div. 4)

    A. Codeforces Checking 题意 每个案例给一个字符,如果在 "codeforces" 中出现过,输出 YES,否则输出 NO code /** * @autho ...