CodeForceS#276-A
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.
The first line contains two integers a and m (1 ≤ a, m ≤ 105).
Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No".
1 5
No
3 6
Yes
开始做时,一直没理解那个取模是怎么回事,
#include <iostream>
using namespace std; int main()
{
long long a, m;
bool flag = false;
while(cin >> a >> m)
{
for(int i=; i<=; i++, a = a + (a%m)) ///a的这句话就是题意
if(a % m == )
flag = ; cout << (flag ? "Yes" : "No") << endl;
} return ;
}
最新文章
- [LeetCode] Self Crossing 自交
- JavaScript闭包深入解析
- Xcode7 Cocoapods 安装或更新出现错误
- 练习使用markdown编辑
- JavaScript Patterns 6.3 Klass
- C#-WinForm-如何获取文本框(TextBox)中鼠标,光标位置
- git merge和个git rebase的区别
- java调用Http请求 -HttpURLConnection学习
- luigi学习3-使用luigid
- C++中输入输出流及文件流操作笔记
- BZOJ 1770: [Usaco2009 Nov]lights 燈( 高斯消元 )
- SpringMVC类型转换、数据绑定
- 浅谈 Requests包
- sql server 2000的安装
- 【实验吧】CTF_Web_简单的SQL注入之3
- SQL Server用户自定义数据类型
- Oracle 查看链接数、创建索引等的DDL语句
- kmeans聚类理论篇
- 三、Docker网络
- a标签和p标签不能设置margin