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 ...
随机推荐
- hive与hbase
作者:有点文链接:https://www.zhihu.com/question/21677041/answer/185664626来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注 ...
- $Android制作和使用Nine-Patch图片
Nine-Patch图片是一种经过特殊处理的png图片,能够指定图片的哪些区域可以被拉伸而哪些区域不可以. (一)普通图片被拉伸时的缺陷 有如下xml文件,其中子LinearLayout的背景图片设置 ...
- 【CodeChef】Small factorials(BigInteger笔记)
You are asked to calculate factorials of some small positive integers. Input An integer t, 1<=t&l ...
- level-8
CSS选择器常见的有几种? !important选择器——它是所有选择器里面权重最高的. *选择器——它是所有选择器里面权重最低的.可以为页面所有的标签添加统一样式,多用于页面整体样式调整,但它会增加 ...
- cocos2dx打飞机项目笔记六:GameScene类和碰撞检测 boundingbox
GameScene类虽然是占用游戏最多时间的类,但是里面的东西不是很多,最重要的就是碰撞检测了,碰撞检测代码如下: void GameScene::detectionCrash() { CCArray ...
- windows7下手工搭建Apache2.2 php5.3 Mysql5.5开发环境
Apache2.2(apache_2.2.2-win32-x86-no_ssl)php5.3.5(php-5.3.5-Win32-VC6-x86,请注意选择VC6版本,否则无法加载php5apache ...
- Qt下TCP编程
一.服务器 1.声明一个QTcpServer对象 QTcpServer* serverListener; 2.new出对象 this->serverListener = new QTcpServ ...
- Go 字符串相关-标准库
标准库中有四个包对字符串处理尤为重要: bytes strings strconv unicode strings包提供了许多如字符串的查询.替换.比较.截断.拆分和合并等功能. bytes包也提供了 ...
- 服务器windows 2003 安装SQL 2000+SP4
(在windows 2003安装SQL 2000,对于03系统是没有32位和64位之分的) (32位系统需要重启机器,64不需要) 在站点下载数据库 解压后有两个文件夹 首先安装SQL2000 第1步 ...
- linux下java unrecognized class file version错误的解决
root@Mr javaPC]# java HelloWorldException in thread “main” java.lang.ClassFormatError: HelloWorld (u ...