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

Copy
8 6

Sample Output 1

Copy
16

For example, 16 is a multiple of 8 but not a multiple of 6.


Sample Input 2

Copy
3 3

Sample Output 2

Copy
-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的更多相关文章

  1. 【AtCoder】AtCoder Petrozavodsk Contest 001

    A - Two Integers 如果\(X\)是\(Y\)的倍数的话不存在 可以输出\(X \cdot (\frac{Y}{gcd(X,Y)} - 1)\) 代码 #include <bits ...

  2. AtCoder Petrozavodsk Contest 001 B - Two Arrays

    Time limit : 2sec / Memory limit : 256MB Score : 300 points Problem Statement You are given two inte ...

  3. AtCoder Petrozavodsk Contest 001

    第一场apc,5H的持久战,我当然水几个题就睡了 A - Two Integers Time limit : 2sec / Memory limit : 256MB Score : 100 point ...

  4. AtCoder Grand Contest 001 C Shorten Diameter 树的直径知识

    链接:http://agc001.contest.atcoder.jp/tasks/agc001_c 题解(官方): We use the following well-known fact abou ...

  5. AtCoder Regular Contest 063 E:Integers on a Tree

    题目传送门:https://arc063.contest.atcoder.jp/tasks/arc063_c 题目翻译 给你一个树,上面有\(k\)个点有权值,问你是否能把剩下的\(n-k\)个点全部 ...

  6. AtCoder Grand Contest 001 D - Arrays and Palindrome

    题目传送门:https://agc001.contest.atcoder.jp/tasks/agc001_d 题目大意: 现要求你构造两个序列\(a,b\),满足: \(a\)序列中数字总和为\(N\ ...

  7. Atcoder Grand Contest 001 D - Arrays and Palindrome(构造)

    Atcoder 题面传送门 洛谷题面传送门 又是道思维题,又是道把我搞自闭的题. 首先考虑对于固定的 \(a_1,a_2,\dots,a_n;b_1,b_2,\dots,b_m\) 怎样判定是否合法, ...

  8. Atcoder Grand Contest 001 F - Wide Swap(拓扑排序)

    Atcoder 题面传送门 & 洛谷题面传送门 咦?鸽子 tzc 来补题解了?奇迹奇迹( 首先考虑什么样的排列可以得到.我们考虑 \(p\) 的逆排列 \(q\),那么每次操作的过程从逆排列的 ...

  9. AtCoder Grand Contest 001

    B - Mysterious Light 题意:从一个正三角形边上一点出发,遇到边和已走过的边则反弹,问最终路径长度 思路:GCD 数据爆long long #pragma comment(linke ...

随机推荐

  1. pyhton3 sys模块

    Python常用模块之sys sys模块提供了一系列有关Python运行环境的变量和函数. 1 ). sys.stdin 标准输入流.2 ).sys.stdout 标准输出流.3 ). sys.std ...

  2. h => h(App)解析

    在创建Vue实例时经常看见render: h => h(App)的语句,现做出如下解析: h即为createElement,将h作为createElement的别名是Vue生态系统的通用管理,也 ...

  3. django大全

    数据库配置: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME':'dbname', 'USER': 'ro ...

  4. Ubuntu 使用国内apt源

    编辑/etc/apt/source-list deb http://cn.archive.ubuntu.com/ubuntu/ trusty main restricted universe mult ...

  5. springmvc返回视图(解析)

    1.什么是视图? 视图就是展示给用户看的结果.可以是很多形式,例如:html.JSP.excel表单.Word文档.PDF文档.JSON数据.freemarker模板视图等等. 2.传统JSP和JST ...

  6. Nginad广告生成代码分析

    大家都知道实时竞价的广告一般会在一个iframe中,这个iframe会有一个复杂的src.那么这个iframe是如何生成的? 这里分析NginAd作为exchange时,如何让媒体网站通过引用一段ad ...

  7. 手把手教你安装SSL证书升级https

    是不是觉得别人网站前面的小绿锁很好看? 而且,Google官方也正式承认过https是影响搜索排名的一个因素,那么如何将自己的网站全面升级为https呢?今天的内容就介绍一下如何将部署在Nginx的W ...

  8. Android 报错Android - Performing stop of activity that is not resumed

    [原文] FROM STACKOVERFLOW: Just giving my 50 cents on the issue. Catching the exception is indeed one ...

  9. Hbase- Hbase客户端读写数据时的路由流程

    1.客户端先到zookeeper查找hbase:meta所在的RegionServer服务器 2.去hbase:meta表查找自己所要的数据所在的region server 3.去目标region s ...

  10. c++ STL库deque和vector的例子

    头文件wuyong.h: #pragma once #include<iostream> #include<vector> #include<deque> #inc ...