Pat乙级1021题——个位数统计(Python)

PAT (Basic Level) Practice 乙级1021-1030 PAT (Basic Level) Practice 乙级合集1021-1030 阅读详情

代码测试结果为满分

def singleDigit():
    number = raw_input()
    numList = []
    numDict = {}
    for i in range(len(number)):
        numList.append(int(number[i]))
    for i in range(10):
        count = numList.count(i)
        if count != 0:
            numDict[i] = count
    for key in numDict:
        print "%d:%d"%(key, numDict[key])
if __name__ == '__main__':
    singleDigit()
PAT乙级【Java题解合集】 学习完本专栏后,leetcode的简单题应该是没啥问题了,可以去做甲级的题目或者leetcode中等以上难度的题目继续修炼,后续博主会整理并更新算法修炼专栏,欢迎您的订阅!👉🏻算法修炼专栏👈🏻。 阅读详情

相关推荐

PAT乙级 (Basic Level) 目录【Python解】已完结至1125

计算机编程能力考试(Programming Ability Test,简称PAT)是由。旨在培养和展现学生分析问题、解决问题和计算机程序设计的能力,计算机程序设计人才,并为企业选拔人才提供。

新时代先锋的博客 1773

【PAT】Python 1021 个位数统计

【PAT】Python 1021 个位数统计

qq_63974399的博客 382

PAT乙级python编程练习(五)

PAT乙级python编程练习(五) PAT乙级python编程练习(五) 1021 个位数统计 1017 A除以B 1018 锤子剪刀布 1019 数字黑洞 1020 月饼 1021 个位数统计 给定一个 k 位整数 N=d​k−110​k−1​+⋯+d1101​+d0(0≤di≤9,i=0,⋯,k−1,dk−1>0)N=d​k−110​k−1​+⋯+d1101​+d...

Hannah的博客 919

1021 个位数统计(python)

给定一个 k 位整数 N=dk−1​10k−1+⋯+d1​101+d0​ (0≤di​≤9, i=0,⋯,k−1, dk−1​>0),请编写程序统计每种不同的个位数字出现的次数。例如:给定 N=100311,则有 2 个 0,3 个 1,和 1 个 3。 输入格式: 每个输入包含 1 个测试用例,即一个不超过 1000 位的正整数 N。 输出格式: 对 N 中每一种不同的个位数字,以 D:M 的格式在一行中输出该位数字 D 及其在 N 中出现的次数 M。要求按 D 的升序输出。 输入样例:

humingyi0629的博客 1197

PAT_乙级_1021,python中 / 与 //

Python中的除法 第一种是:/ ,普通的除法。 第二种是:// ,官方称为地板除(floor division),得到的结果永远是整数。 对于除法,官方的解释是这样的: Division (/) always returns a float. To do floor division and get an integer result (discarding any fractional result) you can use the // operator; to calculate the remainder you can use %. 我们大概了解了除法( ̄︶ ̄):up-right_arrow: ,而在PAT乙

手把手调试AD9653的LVDS数据采集:从VIO抓波形到用F0/F8帧对齐的实战心得

本文详细介绍了AD9653高速ADC与Xilinx 7系列FPGA(如7z035)的LVDS数据采集调试实战经验。从硬件环境搭建、Vivado工具链配置到LVDS数据对齐技巧,重点分享了利用VIO抓取波形和使用F0/F8帧对齐的实用方法,帮助工程师快速解决高速数据采集系统中的信号完整性问题。

weixin_29169899的博客 702

Python:1021 个位数统计

文章目录一、题目二、代码 一、题目 二、代码 num = input() data = [] for i in num: if int(i) not in data: data.append(int(i)) data.sort() for i in data: print("%d:%d" % (i,num.count(str(i)))) ...

南淮北安的博客 1251

ComfyUI实战:AnimateDiff与ControlNet结合,打造无缝风格化视频转绘

本文详细介绍了如何利用ComfyUI平台,结合AnimateDiff与ControlNet插件,实现高质量的视频风格化转绘。通过搭建节点工作流、调整关键参数,有效解决画面闪烁与失真问题,并分享了进阶玩法与常见问题解决方案,帮助用户轻松打造流畅、风格统一的动态视觉效果。

weixin_29039773的博客 338

PTA 1021 个位数统计(Python版)

PAT (Basic Level) Practice (中文)

weixin_55730361的博客 509

省一蓝桥杯嵌入式-09RTC实时时钟

RTC(Real-Time Clock)实时时钟,是一个独立的定时器RTC模块拥有一组连续的计数的计数器,在响应软件配置下,可提供时钟、日历、闹钟功能RTC能提供年月日时分秒等信息(可设置)在系统复位或从待机模式唤醒后,RTC的设置时间维持不变(这个我没实现,复位后时间也重置了,有能力的可以自己研究一下)持续时间跟踪:在主系统断电后或处于低功耗模式时,RTC仍继续工作,原理是有额外的电池为其供电(蓝桥杯板子没有这个备用电源,该功能无效。

qq_46392331的博客 1729

基础入门篇 | YOLOv8 项目【训练】【验证】【推理】最简单教程 | YOLOv8必看 | 最新更新,直接打印 FPS,mAP50,75,95

三个文件搞定YOLOv8【训练】【验证】【推理】🚀🚀🚀

Coding... 2万+

PTA 1021 个位数统计 python

给定一个 k 位整数 N=d10+⋯+d10+d(0≤d>0),请编写程序统计每种不同的个位数字出现的次数。例如:给定 N=100311,则有 2 个 0,3 个 1,和 1 个 3。

jzb的博客 338

思科 MIB 库

思科 MIB

m0_54931486的博客 770

PAT乙级_1021 个位数统计_Python_AC解法_无疑难点

本文介绍了PAT乙级1021题"个位数统计"的Python解法。题目要求统计给定正整数中每个数字0-9出现的次数并按升序输出。作者采用字符串处理方式,直接遍历0-9并使用count()方法统计每个数字出现次数,最后按要求格式输出结果。虽然作者自谦代码可能存在命名不规范等问题,但该解法简洁高效,时间复杂度为O(10n)。文章特别说明该解法具有个人风格,欢迎读者提出优化建议,并指出本题无明显难点的特点。

CongQianS1的博客 379

vue2/3 - H5 移动端网页中调用手机摄像头扫描二维码 / 条形码功能,在h5手机网页里调起相机摄像头进行二维码或条形码扫描效果详细教程(详细示例组件源码,一键复制开箱即用!)

vue扫描二维码条形码,vue网页调用摄像头扫二维码条形码,vue移动端如何实现调用相机扫描二维码,vue移动端扫一扫功能,vue怎么做移动端h5扫一扫功能,vue识别二维码和条形码,vue实现点击按钮调用摄像头扫码,vue调用本地摄像头实现拍照功能,Vue中如何进行二维码生成与扫描,如何实现vue在手机浏览器中调用摄像头实现扫描二维码功能,VUE项目移动端H5调用摄像头扫码,vue项目中实现H5调取摄像头,网页调用摄像头实现二维码扫描功能,vue调用手机摄像头,vue在调用摄像头扫码,vue自定义打开摄像

✅ 精选推荐文章 1万+

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

pat乙级1021 个位数统计 (15 分)python

基本没难度 记得用count方法 省事 inp=list(input()) inpset=sorted(set(inp))#集合去重 再拍个序 满足题目要求 for i in inpset: print(f"{i}:{inp.count(i)}")

weixin_47234647的博客 137

深度学习工具包 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乙级—1021. 个位数统计 (15)-native

给定一个k位整数N = dk-1*10k-1 + … + d1*101 + d0 (0<=di<=9, i=0,…,k-1, dk-1>0),请编写程序统计每种不同的个位数字出现的次数。例如:给定N = 100311,则有2个0,3个1,和1个3。输入格式:每个输入包含1个测试用例,即一个不超过1000位的正整数N。输出格式:对N中每一种不同的个位数字,以D:M的格式在一行中输出该位数字D及其在N中

Ken 1218

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

PAT乙级合集——python实现(持续更新中~)

最近在巩固python编程能力,本文用于记录python实现的PAT乙级刷题索引,以及在刷题过程中总结的一些规则和经验~ 刷题建议:PAT乙级都是些简单的题目,如果是刷题的同学可以直接按照题号顺序刷即可~ 刷题笔记和规则整理: 合集: 乙级编号 标题 PAT 1001 害死人不偿命的(3n+1)猜想(15分) PAT 1002 写出这个数 (20分) PAT 1003 我要通过!(20分) PAT 1004 成绩排名 (20分) PAT 1005 继续(3n+1)猜想(25分

crayonjingjing的博客 1205

(Python)PAT 乙级学习

感觉用Python写,太取巧了 都有点不敢相信了 文章目录一、真题练习 一、真题练习 1001 1002

南淮北安的博客 727

PAT乙级_合集_Python_AC解法_已完结至1125题

本文是针对PAT乙级考试Python解题的优化指南。作者发现虽然多数题目能顺利通过,但部分代码在提交时会出现错误或超时,而PAT系统不提供详细反馈。现有的Python解题资料较少且部分存在效率问题。文章旨在记录解题过程中的卡点、优化方法和最终AC代码,为使用Python的考生提供参考。目前优先更新前50题中较难的题目,后续会逐步补充其他题目。每道题将详细讲解解题思路以弥补代码注释不足的问题,帮助读者理解优化过程。

CongQianS1的博客 861

PAT(乙级1021)——个位数统计

/* * Copyright (c) 2014, 烟台大学计算机学院 * All rights reserved. * 文件名称:test.cpp * 作 者:李晓凯 * 完成日期:2019年 9 月 3 日 * 版 本 号:v1.0 * * 问题描述: * 输入描述: * 程序输出: */ 给定一个 k 位整数 N=d​k−1​​10​k−1​​+⋯+d​1​​1...

独一无二的我的专栏 277

PAT乙级 (Basic Level) python3语言实现代码(全120道)

PAT乙级 (Basic Level) Practice (中文)题目共120道。本文所有代码均用python3语言编写,除了11道题因为个别测试点超时未通过外,其他均通过。

梁山伯的专栏 937

PAT 乙级(Python) #1021 个位数统计 (15 分)

#1021 个位数统计 (15 分) 代码展示: data = input() d = {} for digit in data: d[int(digit)] = d.get(int(digit),0) + 1 for i in range(10): if d.get(i,0) != 0: print(str(i)+":"+str(d[i])) 测评结果:

敲代码的小风 240
上一篇: Pat乙级1020题——月饼(Python)有一个结果是非零返回
下一篇: Pat乙级1022题——D进制的A+B(Python)
coder_wu
博客等级 码龄8年 5粉丝 29原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值