zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    Assets Pipeline
    how to execute-shell-commands by ruby
    DFS---迷宫问题
    病毒感染监测
    RE数组开多大?
    C++如何输入含空格的字符串
    后缀算术表达式
    中缀表达式转化为后缀表达式
    基于两端操作的循环队列的实现---怎么判断队满??
    循环队列--忘记分配空间和如何用tag判断队空队满
  • 原文地址:https://www.cnblogs.com/ya-cpp/p/4077771.html
Copyright © 2011-2022 走看看