pat1069 The Black Hole of Numbers
来源:互联网 发布:家庭千兆网络组建方案 编辑:程序博客网 时间:2024/05/17 14:20
#include<cstdio>#include<iostream>#include<algorithm>#include<vector>#include<queue>#include<string>#include<cstring>#include<cmath>#include<map>using namespace std;int l(int n){int bit[5];int ret = 0;bit[0] = n%10,n/=10;bit[1] = n%10,n/=10;bit[2] = n%10,n/=10;bit[3] = n%10;sort(bit,bit+4);for(int i = 0;i<4;i++){ret*=10;ret+=bit[i];}return ret;}int h(int n){int bit[5];int ret = 0;bit[0] = n%10,n/=10;bit[1] = n%10,n/=10;bit[2] = n%10,n/=10;bit[3] = n%10;sort(bit,bit+4);for(int i = 3;i>=0;i--){ret*=10;ret+=bit[i];}return ret;}int main(){int n,m;while(scanf("%d",&n)!=EOF){m = n;while(1){int hh = h(n),ll = l(n);n = hh-ll;if(n == 0){printf("%04d - %04d = 0000\n",m,m);break;}printf("%04d - %04d = %04d\n",hh,ll,n);if(n == 6174)break;}} return 0;}
0 0
- pat1069 The Black Hole of Numbers
- 1069. The Black Hole of Numbers (20)
- 1069. The Black Hole of Numbers (20)
- 1069. The Black Hole of Numbers
- PAT 1069. The Black Hole of Numbers
- PAT 1069. The Black Hole of Numbers
- 1069. The Black Hole of Numbers (20)
- 1069. The Black Hole of Numbers
- 1069. The Black Hole of Numbers (20)
- 1069. The Black Hole of Numbers (20)
- 1069. The Black Hole of Numbers (20)
- 1069.The Black Hole of Numbers
- 1069. The Black Hole of Numbers (20)
- 1069. The Black Hole of Numbers (20)
- 1069. The Black Hole of Numbers
- 1069. The Black Hole of Numbers (20)
- 1069. The Black Hole of Numbers (20)
- A1069 . The Black Hole of Numbers (20)
- Prime Ring Problem
- Android Studio安装后Fetching android sdk component information超时的解决方案
- 基于bootstrup的jQuery超酷hero幻灯片特效
- HTML5实现Winamp2.9音频播放器插件
- HDU 2157解题报告
- pat1069 The Black Hole of Numbers
- ORACLE 10G 官方文档演示:查找手工建库语句
- 动态数组使用
- 3T 硬盘读写速度小测
- flume-ng+Kafka+Storm+HDFS 实时系统搭建
- HDOJ 1219 AC Me(有问题!)
- iOS中UIScrollView实现图片循环播放
- 简要说明在matlab中如何转化UCI数据为libsvm库可用数据并举例如何使用
- [BZOJ 2243] 染色