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. MongoDB从入门到实战之MongoDB工作常用操作命令

    前言: 上一章节我们快速的在Docker容器中安装了MongoDB,并且通过Navicat MongoDB可视化管理工具快速的连接.创建数据库.集合以及添加了文档数据源.这一章节我们主要是了解一下在日 ...

  2. ArcGIS工具 - 导出空数据库

    有时,需要根据已有的成果数据创建一个空的数据库模板文件,用于新的编辑或对外发布.那么,如果又快又好的创建呢?为源GIS为您编写了一个导出空数据库工具,它可以实现"一键"快速导出任意 ...

  3. WPF中使用WebView2控件

    目录 WebView2简介 概述 优势 支持的运行时平台 进程模型 基本使用 安装WebView2运行时 安装WebView2Sdk 打开一个网页 导航事件 打开一个网页的过程 更改url的过程 空u ...

  4. SqlServer服务中利用触发器对指定账户进行登录ip限制提升安全性

    转眼间上次写文章已经是 2022年12月15日的事情啦,本来从2022年7月份开始写作之后保持着每周一篇,然而从12月15日后断更了这么久,经历了,隔离.阳.过年.从今天开始继续坚持写作,本片文章给大 ...

  5. DataX插件二次开发指南

    一. DataX为什么要使用插件机制? 从设计之初,DataX就把异构数据源同步作为自身的使命,为了应对不同数据源的差异.同时提供一致的同步原语和扩展能力,DataX自然而然地采用了框架 + 插件 的 ...

  6. Monkey 命令

    1) 参数:  -p 参数-p用于约束限制,用此参数指定一个或多个包(Package,即App).指定 包之后,Monkey将只允许系统启动指定的APP.如果不指定包,Monkey将允许系统启动设备中 ...

  7. Python风格规范(转载)

    Python风格规范(转载) https://zh-google-styleguide.readthedocs.io/en/latest/google-python-styleguide/python ...

  8. vue3 ts遇到的问题

    main.ts中的 createApp(App),只作用于一个,如果,有两个,则并不是一个对象,另一个会不生效

  9. Linux xsync命令脚本

    功能:在主机上分发文件到其他机器 在主机machine136上进行如下操作(master) 1.安装 rsync yum install -y rsync 2.bin下创建 xsync 转自:(82条 ...

  10. Vue22 VueCli 脚手架

    1 简介 CLI 是 Command-Line Interface, 翻译为命令行界面, 但是俗称脚手架 Vue CLI是一个官方发布 vue.js 项目脚手架 使用 vue-cli 可以快速搭建 V ...