Codeforces 476A - Dreamoon and Stairs 水题
2017-07-18 11:13
477 查看
题解:关键在于找出最小最大步数 如果二者之间能整除m的话就输出步数否则输出-1
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int a[100010];
int main()
{
int n,m;
while(cin>>n>>m){
int flag=1;
for(int i=(n+1)/2;i<=n;i++){
if(i%m==0){
flag=0;
cout<<i<<endl;
break;
}
}
if(flag) cout<<-1<<endl;
}
return 0;
}
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int a[100010];
int main()
{
int n,m;
while(cin>>n>>m){
int flag=1;
for(int i=(n+1)/2;i<=n;i++){
if(i%m==0){
flag=0;
cout<<i<<endl;
break;
}
}
if(flag) cout<<-1<<endl;
}
return 0;
}
相关文章推荐
- codeforces—— 476A —— Dreamoon and Stairs
- CodeForces 476A Dreamoon and Stairs
- 【Codeforces Round 272 (Div 2)A】【贪心 暴力 水题】Dreamoon and Stairs n个台阶每次走一步或两步是否有步数恰好为m倍数
- Codeforces Round #272 (Div. 2) A. Dreamoon and Stairs 水题
- CodeForces 682A Alyona and Numbers (水题)
- Codeforces 486A Calculating Function(水题)
- 水题CodeForces 120C
- 【打CF,学算法——一星级】CodeForces 701A Cards(水题)
- 【CodeForces 628A】Tennis Tournament(水题)
- CodeForces 288A Polo the Penguin and Strings (水题)
- Codeforces 812C Sagheer and Nubian Market【二分】水题
- Codeforces 652B z-sort【水题】
- codeforces 746 A.Compote【水题】
- 【CodeForces 618A】Slime Combining(水题)
- codeforces 667A A. Pouring Rain(水题)
- Codeforces 873C Strange Game On Matrix【贪心】水题
- codeforces 673A A. Bear and Game(水题)
- CodeForces - 518A Vitaly and Strings(水题)
- Codeforces 66A:Petya and Java(水题)
- Codeforces 382A Ksenia and Pan Scales(水题)