Hangzhou Electric Acm1222--wolf and rabbit~~ greatest common divisor

Source: Internet
Author: User
Tags greatest common divisor

The meaning of the title is: the Rabbit casually hide in a hole, the wolf from the hole No. 0 began to find, every time to find the next is a number of M, all the holes formed ring.

Input m and n, Hole is number No. 0 to n-1.

The greatest common divisor of M and N is 1, and the wolf can be found in every hole. Otherwise, some holes are ignored, and those holes are safe.

The following is the code for the AC:

#include <iostream>using namespace Std;int GCD (int a, int b) {int c;while (b) {c = a% B;a = B;b = C;} return A;} int main () {int m, n, i;cin >> i;while (i--) {cin >> m >> n;if (GCD (m, n) = = 1) cout << "NO" << E Ndl;elsecout << "YES" << Endl;} return 0;}


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Hangzhou Electric Acm1222--wolf and rabbit~~ greatest common divisor

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.