Chef and Prime Divisors Problem code: CHAPD (GCD Problem), divisorschapd

Source: Internet
Author: User

Chef and Prime Divisors Problem code: CHAPD (GCD Problem), divisorschapd

Question:

Given two numbers, n, m, find if all prime factors of m can be n, the output is "Yes", OR "No ".

Text:


3120 75128 167 8Output:YesYesNo

Until the maximum number of public appointments is 1, you can check whether the latter is 1.


# Include <iostream> # include <algorithm> # include <cstdio> # include <cstring> # include <cmath> # include <math. h ># include <queue> # define inf 0x3f3f3fusing namespace std; long gcd (long n, long m) {return m = 0? N: gcd (m, n % m); // you forgot to add return WA several times ..} Int main () {long n, m, linoleic; cin> linoleic; while (linoleic --) {cin> n> m; long k = gcd (n, m); while (k> 1) {m = m/k; k = gcd (n, m);} if (m = 1) cout <"Yes" <endl; else cout <"No" <endl;} return 0 ;}


Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.