Codeforces Round #272 (Div. 2) A

CS1237卡尔曼滤波实战:如何用24位ADC实现电子秤级精度? 本文详细介绍了如何利用CS1237 24位ADC芯片结合卡尔曼滤波算法实现电子秤级精度测量。通过解析CS1237硬件特性、卡尔曼滤波原理及STM32驱动优化,提供了一套完整的解决方案,包括多通道支持、驱动代码实现和性能调优技巧,适用于工业测量和嵌入式开发领域。 阅读详情

题目:

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;
}


URScript介绍 优傲机器人(Universal Robots)是丹麦工业协作机器人制造商,2005年成立,2015年被泰瑞达收购。其自研编程语言URScript基于Python语法,专为机器人控制优化,支持运动指令、IO控制等功能,具有类Python的简洁语法和实时性特点。URScript提供丰富的API,支持变量赋值、条件判断、循环及函数定义等编程结构,参数按值传递。用户可通过该语言在Polyscope界面编写程序,实现自动化任务。目前优傲在全球20多个办事处为多国客户提供服务。 阅读详情

相关推荐

昇腾910安装驱动出错,降低Centos7.6的内核版本

Centos7.6 启动内核修改,解决昇腾910安装驱动错误的问题。

深蓝 3300

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

ArcGIS基础实战:面数据拓扑创建和错误修改全流程

通过下图的操作我们可以发现,图层的【Shape_Length】和【Shape_Area】字段的数值都发生了改变,表明两个图层重叠的那一部分图斑合并到另一个图班上,其面积会减小、长度会变大(自己重新计算一下也可以得到此验证结果的)。如图【拓扑实验结果】文件夹里右键,新建【文件地理数据库】,并进行命名为【xx拓扑检查】备注:养成良好的命名习惯。然后在【xx拓扑检查】下右键打开【新建要素数据集】,并对数据集进行命名为【XX拓扑】,然后进行下一步设置。在【KK拓扑】数据集上右键,新建【拓扑】。

yuanYW7556的博客 1万+

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

STM32F407VET6与CH395Q串口通信实战:从零搭建以太网客户端(附完整代码)

本文详细介绍了基于STM32F407VET6微控制器与南京沁恒微CH395Q以太网芯片,通过串口通信从零搭建TCP客户端应用的完整实战过程。内容涵盖硬件连接、驱动层设计、基于FreeRTOS的任务实现以及核心调试技巧,并提供了完整的代码示例,帮助嵌入式开发者快速实现设备联网功能。

weixin_29179311的博客 415

如何安装最新版本的 SAP ABAP Development Tool ( ADT ) ,并且能够随时升级

下载链接:https://tools.hana.ondemand.com/#abap 首先安装 Eclipse IDE for Java Developers 找到适合自己操作系统的 Eclipse 安装包: 安装之后,打开Eclipse: Install -> New Softwares, 输入 url:https://tools.hana.ondemand.com/latest 全部安装: 安装完毕之后,新建一个 ABAP Project,本地 SAP GUI 里添加的系统,会自动带出来:

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 4280

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

智启古文字新章:AI、ML与大数据驱动的知识图谱构建

摘要:本文聚焦AI、ML与大数据驱动的古文字知识图谱构建。开篇点明古文字研究困境,凸显技术革新迫切性。随后阐释AI、ML、大数据基础概念,详解其在图谱构建里的数据采集、知识抽取、关系挖掘运作流程,穿插线性代数、概率论等数学原理。实战展示殷商甲骨文图谱搭建全程,含数据处理、模型训练。还探讨跨模态融合等前沿挑战应对,兼述技术融合衍生的教育科普革新、伦理文化责任、国际合作交流,勾勒古文字数字永生的长远愿景。

专注于人工智能、软件开发、工控自动化、工厂数字化及智能化等领域,希望和大家共同进步! 1615

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

Dreamoon and Stairs

gwq5210的专栏 617

科技与伦理的平衡点:人类计算的伦理

科技与伦理的平衡点:人类计算的伦理 关键词 科技与伦理 人类计算 隐私问题 道德决策自动化 公平性与偏见 法律与社会责任 摘要 本

AI天才研究院 1162

银河麒麟V10等保加固清单:安全基线配置一篇搞定(附逐项检查表)

通过限制使用SSH直接以root身份登录,禁用公钥登录的方式加强SSH服务的安全性。更改SSH默认端口可在一定程度上防止被黑客使用大批量扫描方式攻击。通过修改SSH的配置文件限制可以使用SSH服务远程管理的主机。

信创运维工程师 · 银河麒麟 & 容器实战 | 金融生产环境迁移·等保加固 | 142篇原创·17万+阅读 817

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

深入理解Android音视频同步机制(三)NuPlayer的avsync逻辑

本文深入介绍了NuPlayer的avsync逻辑和原理

张晖的专栏 1万+

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

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

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

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

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

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

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、付费专栏及课程。

余额充值