pat b1019 数字黑洞 (20分)

CSP-J第一道模拟题——贪心的小朋友 第一行是一个整数 n,表示糖果的堆数 第二行是由空格分隔的 n 个正整数,即数组 candies,表示每堆糖果的数量。后一个离场的小朋友所拿的糖果总堆数必须小于前一个小朋友(对第一个小朋友没有限制)后一个离场的小朋友所拿的糖果总量必须小于前一个小朋友(对第一个小朋友没有限制)这道题目很简单,但是必须删去无用的部分,看清题目,才能得分哦!输出一行共一个整数,表示最多可能有多少个小朋友吃上了美味的糖果。输出最多可能有多少个小朋友吃上了美味的糖果。离场之后的小朋友才能吃上美味的糖果。每个小朋友可以拿多堆糖果。 阅读详情

题目:https://www.nowcoder.com/pat/6/problem/4045

给定任一个各位数字不完全相同的 4 位正整数,如果我们先把 4 个数字按非递增排序,再按非递减排序,然后用第 1 个数字减第 2 个数字,将得到一个新的数字。一直重复这样做,我们很快会停在有“数字黑洞”之称的 6174,这个神奇的数字也叫 Kaprekar 常数。

例如,我们从6767开始,将得到

7766 - 6677 = 1089
9810 - 0189 = 9621
9621 - 1269 = 8352
8532 - 2358 = 6174
7641 - 1467 = 6174
... ...

现给定任意 4 位正整数,请编写程序演示到达黑洞的过程。

输入格式:

输入给出一个 (0,10​4​​) 区间内的正整数 N。

输出格式:

如果 N 的 4 位数字全相等,则在一行内输出 N - N = 0000;否则将计算的每一步在一行内输出,直到 6174 作为差出现,输出格式见样例。注意每个数字按 4 位数格式输出。

输入样例 1:

6767

输出样例 1:

7766 - 6677 = 1089
9810 - 0189 = 9621
9621 - 1269 = 8352
8532 - 2358 = 6174

输入样例 2:

2222

输出样例 2:

2222 - 2222 = 0000

注意格式,有空格!

#include<iostream>
#include<cstdio>
#include<algorithm> 
using namespace std;

bool cmp(int a,int b)
{
	return a>b;
}

//int型整数转int型数组
void to_array(int n,int num[])
{
	int i=0;
	while(n)  //n的低位存放在数组的低位 
	{
		num[i++]=n%10;  
		n=n/10;
	}
	/*
	for(int i=0;i<4;i++)
	{
		num[i]=n%10;
		n/=10;
	}
	*/
} 


//int型数组转int型整数
int to_number(int num[],int n)
{
	int ans=0;
	int value=1;
	for(int i=0;i<n;i++)  //低位权值小 
	{
		ans+=num[i]*value;
		value*=10;
	}	
	return ans;		
} 
 
int main()
{
	int n;	
	cin>>n;	
	
	int MAX;
	int MIN;
	int a[4]={0};
	
	while(1)
	{
		to_array(n,a);
		sort(a,a+4); //由小到大
		MAX=to_number(a,4);
		sort(a,a+4,cmp);
		MIN=to_number(a,4);
		n=MAX-MIN;
		printf("%04d - %04d = %04d\n",MAX,MIN,n);
		if(n==6174||n==0) break;	
	}
		
	/*
	int a[4]={0};
	to_array(n,a);
		
	sort(a,a+4);
	int MAX=to_number(a,4);
	
	sort(a,a+4,cmp);
	int MIN=to_number(a,4);
		
	while((MAX-MIN)!=6172&&(MAX-MIN)!=0)
	{
				
	}
	*/
	//int a[4]={1,2,3,4};
		
	//cout<<to_number(a,4);
	
	//cin>>n;
	/*
	to_array(n,a);
	for(int i=0;i<4;i++)
	{
		cout<<a[i];
	}
	*/
	return 0;
}

 

图解联合概率密度、边缘概率密度、条件概率密度之间的关系 简要图解联合概率密度、边缘概率密度、条件概率密度之间的关系 阅读详情

相关推荐

SAP S4业务伙伴(BP)实战指南:从角色分配到数据同步的完整流程

本文详细解析了SAP S4业务伙伴(BP)功能,从基础概念到实战操作,涵盖角色分配、数据同步及常见问题排查。通过BP机制,企业可高效管理客户、供应商等多重身份,实现数据共享和动态切换,显著提升主数据管理效率。特别适合SAP实施顾问和ERP管理员参考。

y2z3a4b5c的博客 870

自我数1250

给定任何正整数n作为起点,可以构造无穷增长的整数序列n ,d(n),d(d(n)),d(d(d(n))),....例如,如果从33开始,下一个数字是33 + 3 + 3 = 39,接下来是39 + 3 + 9 = 51,接下来是51 + 5 + 1 = 57,所以生成序列为:33,39,51,57,69,84,96,111,114,120,123,129,141,......数n被称为d(n)的发生器。在上面的顺序中,33是39的发生器,39是51的发生器,51是57的发生器,依此类推。

sunyixuan123的博客 358

SSTI模板注入及绕过姿势(基于Python-Jinja2)

http://xmctf.top:8962/?name={{%22%22[%22\x5f\x5fclass\x5f\x5f%22]["\x5F\x5Fbase\x5F\x5F"]["\x5F\x5Fsubclasses\x5F\x5F"]()[233]["\x5F\x5Finit\x5F\x5F"]["\x5F\x5Fglobals\x5F\x5F"]["\x5F\x5Fbuiltins\x5F\x5F"]['eval']("\x5F\x5Fimport\x5F\x5F('os'))")}}

Y4tacker的博客 1万+

1019. 数字黑洞

1019. 数字黑洞 给定任⼀个各位数字不完全相同的4位正整数,如果我们先把4个数字按⾮递增排序, 再按⾮递减排序,然后⽤第1个数字减第2个数字,将得到⼀个新的数字。⼀直重复 这样做,我们很快会停在有“数字⿊洞”之称的6174,这个神奇的数字也叫Kaprekar常数。 例如,我们从6767开始,将得到 7766 – 6677 = 1089 9810 – 0189 = 9621 9621 – 1269 = 8352 8532 – 2358 = 6174 7641 – 1467 = 6174 … … 现给定任意

前端学习博客 645

手把手教你用支付宝密钥工具生成RSA2密钥对(含Windows/Mac操作截图)

本文详细介绍了如何使用支付宝密钥工具生成RSA2密钥对,包括Windows和Mac平台的操作步骤与截图。从工具下载、安装到密钥生成、配置支付宝平台,再到开发环境集成实战,手把手教你完成支付宝支付接口对接。特别强调密钥安全管理和最佳实践,帮助开发者避免常见安全隐患。

mongodb5scout的博客 257

Android逆向实战:抖音聊天记录数据库解析与导出(附完整SQL查询)

本文提供了一份Android逆向实战指南,详细解析了抖音聊天记录数据库的结构与导出方法。通过定位核心的`im.db`数据库文件,深度解读conversation_list、msg等关键表结构,并附上完整的SQL查询语句,帮助开发者或研究人员安全、合规地提取和分析本地聊天数据,适用于移动安全研究与数据分析场景。

mango的博客 860

1019 数字黑洞(附详细注释,逻辑分析)

写在前面 实现思路 4位数字转整型数组,排序组合计算出最大、最小值 循环打印输出等式,其中注意每个数字按 4 位数格式输出 最大、最小差值为0或6174,跳出循环注意逻辑代码顺序 题目较简单,时间花费:自定义函数。 10分钟a题 测试用例 input: 6767 output: 7766 - 6677 = 1089 9810 - 0189 = 9621 9621 - 1269 = 835...

kngines 1442

CloudCompare点云变换保姆级教程:从平移、旋转到绕任意点旋转,一次搞定

本文提供CloudCompare点云变换的全面教程,涵盖从基础平移、旋转到绕任意点旋转的高级技巧。通过详细的操作步骤和实战案例,帮助用户掌握点云数据处理的核心技能,提升三维模型对齐和变换的效率与精度。

weixin_28717969的博客 291

1019 数字黑洞

1019 数字黑洞分数 20全屏浏览题目切换布局作者 CHEN, Yue单位 浙江大学给定任一个各位数字不完全相同的 4 位正整数,如果我们先把 4 个数字按非递增排序,再按非递减排序,然后用第 1 个数字减第 2 个数字,将得到一个新的数字。一直重复这样做,我们很快会停在有“数字黑洞”之称的6174,这个神奇的数字也叫 Kaprekar 常数。例如,我们从6767开始,将得到现给定任意 4 位正整数,请编写程序演示到达黑洞的过程。

Emilybloom的博客 200

基于YOLOv8深度学习的火焰与烟雾检测系统详解:UI界面 + YOLOv8 + 数据集的实现

通过自动化检测火焰和烟雾,可以提高响应速度,减少潜在的火灾损失,保障人身和财产安全。此外,应用还会显示标记了检测框的视频画面,方便用户直观了解检测效果。同时,前端界面将使用Streamlit来实现,因其可以快速搭建交互式应用,适合我们的需求。要训练一个有效的火焰和烟雾检测模型,我们需要一个包含火焰和烟雾图片的数据集。为了保证模型的准确性和泛化能力,建议收集至少500张火焰和烟雾的图片,保证数据的多样性和代表性。训练过程中,模型会输出每个Epoch的训练损失和验证准确率,便于我们监控模型的学习情况。

YOLO 1321

cursor AI代码编辑器IDE对接deepseek模型api;字节ai编辑器trae

参考: https://www.cursor.com/ https://platform.deepseek.com/https://www.cursor.com/下载安装后,注册账号登录即可 再高级里选择设置 再模型这注册模型: 模型名称一定要填正确,url地址填好,最后填上秘钥验证

weixin_42357472的博客 1万+

【PAT B1019】数字黑洞 (20 分)

1019数字黑洞(20分) 给定任一个各位数字不完全相同的 4 位正整数,如果我们先把 4 个数字按非递增排序,再按非递减排序,然后用第 1 个数字减第 2 个数字,将得到一个新的数字。一直重复这样做,我们很快会停在有“数字黑洞”之称的6174,这个神奇的数字也叫 Kaprekar 常数。 例如,我们从6767开始,将得到 7766 - 6677 = 1089 9810 - 01...

tqlwsl的博客 218

新能源汽车电机交流电流测量系统精度全链路分析

通过全链路误差建模与瓶颈分析,结合硬件选型优化与软件算法补偿,可将系统精度从4.2%提升至≤1% FS。本文所述方法论已应用于某800V电驱平台开发,实测电流控制精度达±0.8%,为高性能电机控制奠定基础。为例,深入剖析从互感器采集到CAN报文解析的全链路信号处理流程,揭示各环节误差来源及对最终精度的影响,为研发测试提供理论支撑。:±0.1%(电阻温漂与运放开环增益限制):运放增益带宽积(GBW)不足导致高频衰减。:±0.02%/℃(铁氧体材料温敏特性):±0.5%读数(磁芯饱和效应)

优快云-新能源汽车研发测试专业博主 1493

PAT B1019 数字黑洞 (20分)

给定任一个各位数字不完全相同的 4 位正整数,如果我们先把 4 个数字按非递增排序,再按非递减排序,然后用第 1 个数字减第 2 个数字,将得到一个新的数字。一直重复这样做,我们很快会停在有“数字黑洞”之称的6174,这个神奇的数字也叫 Kaprekar 常数。 例如,我们从6767开始,将得到 7766 - 6677 = 1089 9810 - 0189 = 9621 9621 - 12...

jiangjiangjiang6的博客 199

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

PAT B. 1019 数字黑洞 (20分)

代码1: /* 数字黑洞 */ #include <iostream> #include <algorithm> #include <string> using namespace std; bool cmp(char a, char b){ return a > b; } int main() { string str; int temp; cin >> str; str.insert(0, 4-str.length(), '0');//

哈密瓜味的猪 192

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

PAT B 1019 数字黑洞 (20 分)

PAT B 1019 数字黑洞 (20 分) 给定任一个各位数字不完全相同的 4 位正整数,如果我们先把 4 个数字按非递增排序,再按非递减排序,然后用第 1 个数字减第 2 个数字,将得到一个新的数字。一直重复这样做,我们很快会停在有“数字黑洞”之称的 6174,这个神奇的数字也叫 Kaprekar 常数。 例如,我们从6767开始,将得到 7766 - 6677 = 1089 9810 - 0...

stone_2027 286

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

PAT:B1019 数字黑洞(20 分)

PAT:B1019 数字黑洞(20 分) 给定任一个各位数字不完全相同的 4 位正整数,如果我们先把 4 个数字按非递增排序,再按非递减排序,然后用第 1 个数字减第 2 个数字,将得到一个新的数字。一直重复这样做,我们很快会停在有“数字黑洞”之称的 6174,这个神奇的数字也叫 Kaprekar 常数。 例如,我们从6767开始,将得到 7766 - 6677 = 1089 9810 -...

Ecloss 759

PAT_B_1019 数字黑洞 (20 分)【测试点2,3,4通不过】

给定任一个各位数字不完全相同的 4 位正整数,如果我们先把 4 个数字按非递增排序,再按非递减排序,然后用第 1 个数字减第 2 个数字,将得到一个新的数字。一直重复这样做,我们很快会停在有“数字黑洞”之称的 6174,这个神奇的数字也叫 Kaprekar 常数。 例如,我们从6767开始,将得到 7766 - 6677 = 1089 9810 - 0189 = 9621 9621 - 12...

id33749110的博客 2501

PAT A 1069 The Black Hole of Numbers (20 分)/B 1019 数字黑洞 (20 分)

PAT A 1069 The Black Hole of Numbers (20 分)/B 1019 数字黑洞 (20 分) For any 4-digit integer except the ones with all the digits being the same, if we sort the digits in non-increasing order first, and then in non-decreasing order, a new number can be obtained b

weixin_48165493的博客 192

PAT乙级 1017 A除以B (20分) & 1018 锤子剪刀布 (20分) &1019 数字黑洞 (20分)

1017 A除以B (20分) 其实我觉得这题就不简单,可能是我没有刷过题目,使用正常的手算的方式来解题即可。这个位置是最关键的。把第i位或者第i-1位的余数作为被除数和除数相除。 int temp1 = temp / b; aa[i] = temp1;//除数的结果保存到aa temp = temp % b * 10 + (a[i + 1] - '0'); #include<io...

小旻 257

【PAT】甲级A1069 The Black Hole of Numbers (20 分)/乙级B1019 数字黑洞 (20 分)

PAT中A1069和B1019都是数字黑洞问题,这里放上中文版本,方便阅读。 给定任一个各位数字不完全相同的 4 位正整数,如果我们先把 4 个数字按非递增排序,再按非递减排序,然后用第 1 个数字减第 2 个数字,将得到一个新的数字。一直重复这样做,我们很快会停在有“数字黑洞”之称的 6174,这个神奇的数字也叫 Kaprekar 常数。 例如,我们从6767开始,将得到 7766 - 6677 = 1089 9810 - 0189 = 9621 9621 - 1269 = 8352 8532 - 2.

Hekiiu的博客 207

PAT (Basic Level) Practice (中文) B1019 数字黑洞 (20 分)(C++)(排序)

1019 数字黑洞 (20 分) 给定任一个各位数字不完全相同的 4 位正整数,如果我们先把 4 个数字按非递增排序,再按非递减排序,然后用第 1 个数字减第 2 个数字,将得到一个新的数字。一直重复这样做,我们很快会停在有“数字黑洞”之称的 6174,这个神奇的数字也叫 Kaprekar 常数。 例如,我们从6767开始,将得到 7766 - 6677 = 1089 9810 - 0189 = ...

izhxxx的博客 150

PAT-A 1069 The Black Hole of Numbers (20 point(s))/ PAT-B 1019 数字黑洞(20分)

思路:sprintf和sscanf的使用以及sort函数的使用。

qq_38127801的博客 178

PAT 1019 数字黑洞 (20分)(Java)

题目描述   给定任一个各位数字不完全相同的 4 位正整数,如果我们先把 4 个数字按非递增排序,再按非递减排序,然后用第 1 个数字减第 2 个数字,将得到一个新的数字。一直重复这样做,我们很快会停在有“数字黑洞”之称的 6174,这个神奇的数字也叫 Kaprekar 常数。   例如,我们从6767开始,将得到 7766 - 6677 = 1089 9810 - 0189 = 9621 962...

HenryLei的博客 2万+

[PAT B1019/A1069]数字黑洞

[PAT B1019/A1069]数字黑洞 本题是PAT乙级1019题和甲级1069题,这里先放英文原题,要做乙级的朋友们可以直接跳过看后面的中文原题 题目描述 1069 The Black Hole of Numbers (20 分)For any 4-digit integer except the ones with all the digits being the same, if we ...

欢迎来到我的编程小屋 897
上一篇: printf输出格式总结
下一篇: codeup 1818: 最大公约数2
Estrellas_
博客等级 码龄9年 273粉丝 233原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值