CodeForceS#276-A

本文讨论了一个工业工厂采用神秘细节生产规范的问题。每天结束时,工厂必须额外生产一定数量的细节,使得总数除以指定数后余数为该数。然而,从未有客户购买过这些神秘细节,导致生产可能最终停止。通过给定起始细节数量和额外生产数量,文章检查了生产是否最终会停止。
A. Factory
 

One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce  (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory.

The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m).

Given the number of details a on the first day and number m check if the production stops at some moment.

Input

The first line contains two integers a and m (1 ≤ a, m ≤ 105).

Output

Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No".

Sample test(s)
input
1 5
output
No
input
3 6
output
Yes

 开始做时,一直没理解那个取模是怎么回事,

 1 #include <iostream>
 2 using namespace std;
 3 
 4 int main()
 5 {
 6     long long a, m;
 7     bool flag = false;
 8     while(cin >> a >> m)
 9     {
10         for(int i=0; i<=100000; i++, a = a + (a%m)) ///a的这句话就是题意
11             if(a % m == 0)
12                 flag = 1;
13 
14         cout << (flag ? "Yes" : "No") << endl;
15     }
16 
17     return 0;
18 }

 

转载于:https://www.cnblogs.com/ya-cpp/p/4077771.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值