AtCoder Petrozavodsk Contest 001 A - Two Integers
2024-09-04 13:34:57
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<<-;
}
最新文章
- delphi 实现最小化系统托盘
- Oracle执行计划详解
- 队列的JS实现
- OS.js – 开源的 Web OS 系统,赶快来体验
- vs2015打包winform程序遇到的一系列问题
- cmd for备忘
- 转 状态压缩DP
- 用distinct在MySQL中查询多条不重复记录值[转]
- word2007二级标题自动编号不从大标题开始的解决方法
- Java 线程综述
- 【转载】学习C#的28条建议
- Swift学习笔记十五
- 【Zookeeper学习】Apache Zookeeper项目简介
- Decimal
- SGU题目总结
- Linux-Nand Flash驱动(分析MTD层并制作NAND驱动)
- [JSOI2007]建筑抢修
- Docker : Tomcat Clustering with Load Balancer (Tomcat and Nginx)
- JS ----实现复制粘贴功能 (剪切板应用clipboardData)
- (reverse)Palindromes hdu2163