poj1426
2016-03-16 18:47
204 查看
//poj 1426 //看了老半天用有道也没弄明白什么意思,可能是做的题太少了 //题干中 /* 题目: Given a positive integer n, write a program to find out a nonzero (multiple --- 是倍数的意思!!!) multiple m of n whose decimal representation contains only the digits 0 and 1. */ //BFS... //天..我刚刚明白题意..是指作为二进制的m 是n的倍数 即 2-10 10可以整除2 #include<iostream> using namespace std; int a[524300],i,n; int main() { while(cin>>n) { if (!n) break; i=1; a[1]=1%n; while(a[i]) { i++; a[i]=(a[i/2]*10+i%2)%n; } n=0; while(i) { a[n++]=i%2; i>>=1; //位运算,右移表示除以2,速度较快一点 } while(n--) cout<<a ; //用cout打代码速度应该会快一点,还不用考虑数据类型 cout<<endl; } return 0; }
相关文章推荐
- 扒扒数据库长长知识(下载资源组合看)之05 (多行函数_分组数据_分组过滤)
- 学习TensorFlow,线性回归模型
- 杭电1392-凸包
- Windows上Eclipse远程调用Hadoop2.6.0
- 夺命雷公狗---DEDECMS----3快速入门之隐藏
- POJ 2007 Scrambled Polygon
- POJ 2728 (最优比率生成树+二分或者迭代)
- c++线程回调函数调用类成员函数方法-续集
- 写了一个将数据分片的工具,还请大神指正问题(目前只支持list,没搞太复杂)
- T-TPOJ3083
- StartSSL免费SSL证书成功申请-HTTPS让访问网站更安全
- 尾递归
- Android 判断是有前置摄像头
- IOS-获取设备和app基本信息
- Saving HDU
- 不可错过的手机APP常见8种界面导航样式
- 作业三:词频统计
- auto和decltype
- Xcode 6.1 做ipa企业级分发(In-House模式)详细步骤
- C++基础::typeid、type_info