• AtCoder Petrozavodsk Contest 001 A


    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<<-1;
    }
  • 相关阅读:
    webOFBiz10.4
    堆栈知识
    eas bos二次开发总结[第三方jar、jcom、二次开发包放置]
    计算机编程英语词汇(三)
    计算机英语(四)
    KDTable 表达式应用工具类
    Verilog 流水线加法器
    datagridview 积累
    ajax 调用 webserver
    windows7 vs2008问题结合
  • 原文地址:https://www.cnblogs.com/8023spz/p/8413411.html
Copyright © 2020-2023  润新知