Codeforces Round #272 (Div. 2) A

LTE随机接入实战:如何通过PRACH前导码优化小区覆盖半径(附计算公式) 本文深入探讨了LTE网络中PRACH前导码格式对小区覆盖半径的关键影响。通过解析不同前导码格式(如Format 0-3)的物理参数与覆盖能力,提供了核心计算公式与实战Python脚本,指导网络工程师根据覆盖需求、环境多径和容量等因素,科学选择前导码格式以优化边缘用户接入成功率,实现精准的网络规划与优化。 阅读详情

题目:

A. Dreamoon and Stairs
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Dreamoon wants to climb up a stair of n steps. He can climb 1 or 2 steps at each move. Dreamoon wants the number of moves to be a multiple of an integer m.

What is the minimal number of steps making him climb to the top of the stairs that satisfies his condition?

Input

The single line contains two space separated integers n, m (0 < n ≤ 10000, 1 < m ≤ 10).

Output

Print a single integer — the minimal number of moves being a multiple of m. If there is no way he can climb satisfying condition print  - 1 instead.

Sample test(s)
input
10 2
output
6
input
3 5
output
-1
Note

For the first sample, Dreamoon could climb in 6 moves with following sequence of steps: {2, 2, 2, 2, 1, 1}.

For the second sample, there are only three valid sequence of steps {2, 1}, {1, 2}, {1, 1, 1} with 2, 2, and 3 steps respectively. All these numbers are not multiples of 5.


题意分析:

水题一枚,给出一个N。然后分解N,只能分解为1和2。考虑全部分解为1的情况,则最多需要N步,全部分解为2的情况,如果为奇数N/2+1 偶数N/2.然后枚举,验证就行了。

代码:

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>


using namespace std;


int main()
{
    int n,m,i;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        if(n%2==0)
        {
            for(i=n/2;i<=n;i++)
            {
                if(i%m==0)
                {
                    printf("%d\n",i);
                    break;
                }
            }
            if(i==n+1)
                printf("-1\n");
        }
        if(n%2==1)
        {
            for(i=n/2+1;i<=n;i++)
            {
                if(i%m==0)
                {
                    printf("%d\n",i);
                    break;
                }
            }
            if(i==n+1)
                printf("-1\n");
        }
    }
    return 0;
}


直驱风机并网系统次同步振荡机理与振荡源定位方法研究 摘要: 本文针对直驱风机并网系统次同步振荡问题,研究了其产生机理与振荡源定位方法。通过建立系统小信号模型,采用特征值分析法揭示了次同步振荡的产生机制,并分析了电网强度、控制器参数对振荡特性的影响。基于暂态能量流理论,提出了通过计算各元件耗散能量来定位振荡源的方法。在MATLAB/Simulink平台搭建仿真系统验证了所提方法的有效性,为直驱风电场次同步振荡的分析与抑制提供了理论依据。 关键词:直驱风机;次同步振荡;小信号模型;暂态能量;振荡源定位 阅读详情

相关推荐

anaconda安装-超详细版

文章目录一、anaconda安装1.1 anaconda安装地址1.2 安装详细步骤检验安装是否成功更改conda源(后续安装第三方库可以加快速度) 一、anaconda安装 Anaconda 是一个用于科学计算的 Python 发行版,支持 Linux, Mac, Windows, 包含了众多流行的科学计算、数据分析的 Python 包。装anaconda,就不需要单独装python了。 anaconda优点: 1、anaconda里面集成了很多关于python科学计算的第三方库,主要是安装方便,而p

in546的博客 25万+

codeforces Round #272(div2) A解题报告

A. Dreamoon and Stairs time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Dreamoon wants to climb up a stair of

旅行者西瓜 724

Oracle EBS R12.2 安装 -- Step by Step

Oracle EBS R12.2 安装 -- Step by Step

Albert Tan DBA之路 1512

Codeforces Round #272 (Div. 2) 题解

Codeforces Round #272 (Div. 2) A. Dreamoon and Stairs time limit per test 1 second memory limit per test 256 megabytes input standard input output standard outpu

码代码的猿猿 1861

别再为电路自激发愁了:手把手教你用吸波材料搞定微波腔体谐振(附HFSS仿真设置)

本文详细解析了微波腔体谐振问题的工程解决方案,重点介绍了吸波材料的选型、安装工艺及HFSS仿真设置。通过实际案例和计算工具,帮助射频工程师有效抑制腔体自激,提升系统稳定性。特别适用于35GHz毫米波雷达等高频电路设计场景。

weixin_42662293的博客 383

STM32入门教程:WiFi通信

第四步:初始化串口 在生成的代码中,您可以找到一个名为 "USARTx_Init" 的函数,其中 "x" 是您选择的串口号。然后,我们使用 "AT+CIPSEND" 命令发送UDP数据,接收到服务器的回复,并在终端上显示收到的数据。在配置向导中,您可以选择启用USART串口功能,并根据您的硬件连接,将串口设置为与WiFi模块连接的串口。在上述代码中,我们使用了 "HAL_UART_Receive" 函数来接收串口数据,并使用 printf 来在终端上显示收到的数据。如果有任何问题,请随时向我提问。

2401_85258012的博客 1074

Codeforces Round #272 (Div. 2) A. Dreamoon and Stairs

A. Dreamoon and Stairs time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Dreamoon wants to climb up a stair of

自己选择的路,就算跪着也要走完。 1161

【硬件的单元测试 UT 3】PCIe 3.0及信号完整性测试方法

PCIe标准自从推出以来,1代和2代标准已经在PC和Server上逐渐普及,用于满足高速显卡、高速存储设备对于高速数据传输的要求。出于支持更高总线数据吞吐率的目的,PCI-SIG组织在2010年制定了PCIe 3.0,即PCIe 3代的规范,数据速率达到8Gbps。

qq_43416206的博客 1414

Codeforces Round #272 (Div. 2) A Dreamoon and Stairs

Dreamoon and Stairs

gwq5210的专栏 617

PCL RANSAC拟合空间圆【2026最新版】

RANSAC三维点云空间3D圆拟合。博客长期更新,本文最新更新时间为:2026年4月13日。代码在PCL1.15.0中测试通过

点云侠的博客 7455

爬虫反爬:一文掌握 BotBrowser 的原理和使用(能绕过很多验证码的指纹浏览器)

BotBrowser是使用经过修改的Chromium内核(修改Chromium的C++源代码)的隐形浏览器,可靠地绕过Cloudflare、Shape、PerimeterX、Datadome、Akamai、Kasada、hCaptcha和reCAPTCHA。BotBrowser是一个跨平台的自动化工具,它重新定义了web自动化。专为爬虫、RPA(机器人流程自动化)和 Web 测试设计。与 Puppeteer/Selenium 不同,它通过无头模式(Headless)和API 级控制。

数据知道的博客 1万+

Codeforces Round #272 (Div. 2)-A. Dreamoon and Stairs

http://codeforces.com/contest/476/problem/AA. Dreamoon and Stairstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDreamoon wants to climb up a s...

weixin_30770783的博客 104

28-3 文件上传漏洞 -白盒审计绕过

这行代码是用来获取文件名中最后一个点(.)后的部分,也就是文件的后缀名。这个函数会返回以最后一个点(.)开始到字符串末尾的部分,包括点(.)本身。然而,这段代码存在一个潜在的安全风险。攻击者可以利用多个点(.)来构造恶意文件名,以绕过后缀名检查。切换到bp将抓到的上传请求发送到重发器然后改包。先上传一个普通的php文件然后使用bp抓包。

weixin_43263566的博客 392

Codeforces Round #272 (Div. 2) A. Dreamoon and Stairs 水题

A. Dreamoon and Stairs 题目连接: http://www.codeforces.com/contest/476/problem/A Description Dreamoon wants to climb up a stair of n steps. He can climb 1 or 2 steps at each move. Dreamoon wants the numbe...

weixin_33868027的博客 209

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

Codeforces Round #272 (Div. 2)A. Dreamoon and Stairs 水题

A. Dreamoon and Stairs Dreamoon wants to climb up a stair ofnsteps. He can climb1or2steps at each move. Dreamoon wants the number of moves to be a multiple of an integerm. What is the m...

weixin_30322405的博客 700

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

Codeforces Round #272 (Div. 2) A Dreamoon and Stairs(水)

思路:水 #include using namespace std; int main() { int n,m,ans=1e9; scanf("%d%d",&n,&m); for(int i = 1;i<=n;i++) { if(i%m==0 && 2*i>=n) ans = min(ans,i); } if(ans==1e9) printf

围巾的ACM博客 556

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

codeforces Round #272(div2) B解题报告

B. Dreamoon and WiFi time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Dreamoon is standing at the position 0 

旅行者西瓜 817

Codeforces Round #272 (Div. 2)

目测本月没有cf了,明天下午没课,

CHEATBEATER 927

codeforces Round #272(div2) C解题报告

C. Dreamoon and Sums time limit per test 1.5 seconds memory limit per test 256 megabytes input standard input output standard output Dreamoon loves summing up something

旅行者西瓜 934

Codeforces Round #784

网址:Dashboard - Codeforces Round #784 (Div. 4) - Codeforces A. Division?(划分?) 每次测试的时间限制 1 秒 每个测试的内存限制 256 兆字节 输入 标准输入 输出 标准输出 Codeforces按其额定值将其用户分为4个部分: 对于 1 分区:1900≤额定值 对于 2 分区:1600≤额定值≤1899 对于第 3 分区:1400≤额定值≤1599 对于第4分区:评级≤额定值 给定额定值,打印额定值所属的分区。 输.

zhousanguhe的博客 2480

codeforces Round #272(div2) D解题报告

D. Dreamoon and Sets time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Dreamoon likes to play with sets, integ

旅行者西瓜 701

Codeforces Round #272 (Div. 2) B. Dreamoon and WiFi (超几何分布)

题目链接:Codeforces Round #273 (Div. 2) B. Dreamoon and WiFi 题意:“+”表示前进1个单位,“-”表示后退1个单位,问以0为起点经过S1,S2两个命令后达到的位置相同的概率。 思路:统计“+”和“-”的数量。如果S2中的“+”或者“-”比S1中的多,概率是0。其他条件下,形成的是超几何分布。 AC代码: #includ

n-1 1222

Codeforces Round #272 (Div. 2) B

Codeforces Round #272 (Div. 2) B

Notdeep__acm的专栏 1372
上一篇: Codeforces Round #267 (Div. 2) A
下一篇: Codeforces Round #272 (Div. 2) B
Notdeep__acm
博客等级 码龄12年 20粉丝 53原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值