AtCoder Petrozavodsk Contest 001 A - Two Integers
Time limit : 2sec / Memory limit : 256MB
Score : 100 points
Problem Statement
You are given positive integers X and Y. If there exists a positive integer not greater than 1018 that is a multiple of X but not a multiple of Y, choose one such integer and print it. If it does not exist, print −1.
Constraints
- 1≤X,Y≤109
- X and Y are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print a positive integer not greater than 1018 that is a multiple of X but not a multiple of Y, or print −1 if it does not exist.
Sample Input 1
8 6
Sample Output 1
16
For example, 16 is a multiple of 8 but not a multiple of 6.
Sample Input 2
3 3
Sample Output 2
-1
A multiple of 3 is a multiple of 3.
只需要判断x是否是y的倍数。
代码:
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
using namespace std;
int a,b;
int main()
{
cin>>a>>b;
if(a % b)cout<<a;
else cout<<-;
}
AtCoder Petrozavodsk Contest 001 A - Two Integers的更多相关文章
- 【AtCoder】AtCoder Petrozavodsk Contest 001
A - Two Integers 如果\(X\)是\(Y\)的倍数的话不存在 可以输出\(X \cdot (\frac{Y}{gcd(X,Y)} - 1)\) 代码 #include <bits ...
- AtCoder Petrozavodsk Contest 001 B - Two Arrays
Time limit : 2sec / Memory limit : 256MB Score : 300 points Problem Statement You are given two inte ...
- AtCoder Petrozavodsk Contest 001
第一场apc,5H的持久战,我当然水几个题就睡了 A - Two Integers Time limit : 2sec / Memory limit : 256MB Score : 100 point ...
- AtCoder Grand Contest 001 C Shorten Diameter 树的直径知识
链接:http://agc001.contest.atcoder.jp/tasks/agc001_c 题解(官方): We use the following well-known fact abou ...
- AtCoder Regular Contest 063 E:Integers on a Tree
题目传送门:https://arc063.contest.atcoder.jp/tasks/arc063_c 题目翻译 给你一个树,上面有\(k\)个点有权值,问你是否能把剩下的\(n-k\)个点全部 ...
- AtCoder Grand Contest 001 D - Arrays and Palindrome
题目传送门:https://agc001.contest.atcoder.jp/tasks/agc001_d 题目大意: 现要求你构造两个序列\(a,b\),满足: \(a\)序列中数字总和为\(N\ ...
- Atcoder Grand Contest 001 D - Arrays and Palindrome(构造)
Atcoder 题面传送门 洛谷题面传送门 又是道思维题,又是道把我搞自闭的题. 首先考虑对于固定的 \(a_1,a_2,\dots,a_n;b_1,b_2,\dots,b_m\) 怎样判定是否合法, ...
- Atcoder Grand Contest 001 F - Wide Swap(拓扑排序)
Atcoder 题面传送门 & 洛谷题面传送门 咦?鸽子 tzc 来补题解了?奇迹奇迹( 首先考虑什么样的排列可以得到.我们考虑 \(p\) 的逆排列 \(q\),那么每次操作的过程从逆排列的 ...
- AtCoder Grand Contest 001
B - Mysterious Light 题意:从一个正三角形边上一点出发,遇到边和已走过的边则反弹,问最终路径长度 思路:GCD 数据爆long long #pragma comment(linke ...
随机推荐
- webstrom突然不显示文件夹
不知道什么原因,webstrom突然不显示文件夹了,弄得几乎都不能用了... 百度搜了一下解决方案: 问题原因:webstorm自动生成的配置文件 .idea/modules.xml损坏(就是我一开始 ...
- java验证类ValidUtils
ValidUtils.java package com.lyqc.utils; import org.apache.commons.lang.StringUtils; public class Val ...
- mini2440移植uboot 2014.04(六)
上一篇博文:<mini2440移植uboot 2014.04(五)> 代码已经上传到github上:https://github.com/qiaoyuguo/u-boot-2014.04- ...
- Android LCD(三):LCD接口篇【转】
本文转载自:http://blog.csdn.net/xubin341719/article/details/9177085 关键词:Android LCD控制器 Framebuffer PWM 平 ...
- 【P2476】着色方案(记忆化搜索+特殊的DP数组)
这个题代码难度几乎为0,然而思维难度对于蒟蒻来说简直是突破天际啊!首先我思考的是这个油漆的种类只有15种,是不是可以像一道叫做8数码难题的东西暴力15维数组呢..计算发现不可以....空间会直接让你学 ...
- IntelliJ Idea中配置、使用技巧(持续更新)
当前项目配置和全局配置 idea中的File-->settings...和File-->other settings-->Default settings...分别是对当前项目的配置 ...
- java中i=i++问题分析
http://www.ticmy.com/?p=43 重点:局部变量表 和 操作数栈的执行过程. 使用javac编译后再使用javap -c Test反编译这个类查看它的字节码,如下(只摘取main方 ...
- jsp:<c:redirect> 和<c:param> 标签
redirect 标签使用来进行页面之间的重定向,它和传统 JSP 程序中的<jsp:redirect>标记功能相类似.param 标签是和 redirect 一起使用的,它用来进行参数值 ...
- jq中append()、prepend()、after()、before()的区别详解
1.append() - 在被选元素的结尾插入内容(内容的结尾,比如说有个a标签,则是在</a>这个标签之前添加东西) 2.prepend() - 在被选元素的开头插入内容(内容的开始,比 ...
- mouseenter和hover的区别
js中鼠标事件中,mouseenter和hover都可以达到,鼠标悬浮在目标上,触发事件,那么两者效果相同,有什么区别呢. 经过自己亲自试验.发现,mouseenter和hover还是有区别的. ho ...