Codeforces Round #276 (Div. 2) Factory
来源:互联网 发布:怎么健身 知乎 编辑:程序博客网 时间:2024/05/01 07:40
题目叙述:
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 werex details in the factory storage, then by the end of the day the factory has to produce (remainder after dividingx 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 bym).
Given the number of details a on the first day and numberm check if the production stops at some moment.
点击打开链接
题目翻译:
开始工厂存储x件产品,但是都买不出去。他们每天生产x mod m件产品,但是也卖不出去(呃~~~)。于是产品就一直在囤积,如果某天x可以整除m,那么工厂就面临大问题了。
算法分析:
设每天其实的产品数位a,第二天起始的产品数为a+a%m,判断a+a%m是否可以被m整除.
判断(a+a%m)是否会重复出现。
我的代码:
#include<iostream>using namespace std;int main(){ int a,m; int flag=1; int s[100000]={0}; cin>>a>>m; while(flag) { a=(a+a%m)%m; if(!a) { cout<<"Yes"<<endl; flag=0; } if(s[a]==1) //判断是否重复出现 { cout<<"No"<<endl; flag=0; } s[a]=1; //数字出现一次 } return 0;}
- Codeforces Round #276 (Div. 2) Factory
- Codeforces Round #276 (Div. 2)A. Factory 数学+规律
- Codeforces Round #401 (Div. 2) E. Hanoi Factory 贪心+栈
- Codeforces Round #401 (Div. 2):E. Hanoi Factory
- Codeforces Round #401(Div. 2)E. Hanoi Factory【贪心+栈】
- Codeforces Round #401 (Div. 2)Hanoi Factory CDQ分治
- Codeforces Round #401 (Div. 2 )E. Hanoi Factory
- Codeforces Round #401 (Div. 2) E. Hanoi Factory 贪心+栈
- 【Codeforces Round 276 (Div 2)A】【暴力】Factory 数增余数直到余数为0
- Codeforces Round #276 (Div. 2)
- Codeforces Round #276 (Div. 2)
- Codeforces Round #276(Div. 2)
- Codeforces Round #276 (Div. 2)
- Codeforces Round #276 (Div. 2)
- Codeforces Round #276 (Div. 2)
- 【codeforces】Codeforces Round #276 (Div. 2) 题解
- Codeforces Round #401 (Div. 2)E. Hanoi Factory(离散化+线段树)
- Codeforces Round #276 (Div. 2) C
- Android动态加载XML文件及控件来简单实现QQ好友印象的功能
- 新建Maven+Spring项目错误集锦
- uva 11384 Help is needed for Dexter(模拟)
- [Java]Eclipse配置JDK的图解步骤
- USACO1.2.4 Palindromic Squares (palsquare)
- Codeforces Round #276 (Div. 2) Factory
- Populating Next Right Pointers in Each Node II
- Java 对象数组初始化 和 基本类型数组初始化的区别
- Activity的启动模式
- 下位机单片机c语言发送数据到串口,上位机pc机java语言获取端口数据
- Serial Port 波形分析
- android5 sdk 下载地址大全
- 开源中国iOS客户端涉及的知识点(下)
- dynamic programming in Date Structures and Algorithm Analysis in C