【python】求水仙数
for i in range(100, 1000):
sum = 0
temp = i
while temp:
sum = sum + (temp%10) ** 3
temp //= 10 # 注意使用地板除哦~
if sum == i:
print(i)
来源:小甲鱼习题
【python】求水仙数的更多相关文章
- php 求水仙花数优化
水仙花数是指一个n位数(n>=3),它每一个位上数字的n次幂之和等于它本身,n为它的位数.(比如:1^3+5^3+3^3 = 153) 水仙花数又称阿姆斯特朗数. 三位的水仙花数有4个:153, ...
- 二、求水仙花数,打印出100-999之间所有的"水仙花数"
所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身. 例如:153是一个"水仙花数",因为153=1的三次方+5的三次方+3的三次方 public c ...
- 帮初学者改代码——playerc之“练习:求完数问题”(下)
前文链接:帮初学者改代码——playerc之“练习:求完数问题”(上) 再来看看be_ferfect()应该如何改. be_ferfect()函数的功能是判断number是否为完数,同时把因子对写入d ...
- 帮初学者改代码——playerc之“练习:求完数问题”(上)
原文:“练习:求完数问题” 原代码: // #include <stdio.h> #include <stdlib.h> #include <math.h> #de ...
- openmp 并行求完数
// GetWanShu.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include "omp.h" #inclu ...
- 使用python求字符串或文件的MD5
使用python求字符串或文件的MD5 五月 21st, 2008 #以下可在python3000运行. #字符串md5,用你的字符串代替'字符串'中的内容. import hashlib md5=h ...
- d008: 求两数的整数商 和 商
内容: 求两数的整数商 和 商 ,商保留两位小数 输入说明: 一行 两个整数 输出说明: 一行,一个整数,一个实数(两位小数) 输入样例: 12 8 输出样例 : 1 1.50 #include ...
- d007: 求两数的整数商 和 余数
内容: 求两数的整数商 和 余数 输入说明: 一行两个整数 输出说明: 一行两个整数 输入样例: 18 4 输出样例 : 4 2 #include <stdio.h> int main ...
- ZOJ3574(归并排序求逆数对)
Under Attack II Time Limit: 5 Seconds Memory Limit: 65536 KB Because of the sucessfully calcula ...
随机推荐
- [Webpack 2] Expose modules to dependencies with Webpack
When you have a dependency that has dependencies on global variables (like jQuery or lodash) or assu ...
- [Whole Web] [Node.js, PM2] Controlling runaway apps using pm2
shows how to enable features in your pm2 config file that allow you to prevent runaway apps from bri ...
- QT显示输出及其桌面
/* 应用程序桌面 */ QDesktopWidget* desktop = QApplication::desktop(); /* 指定显示器的屏幕尺寸(1024 * 768) */ QRect ...
- linux shell read command-Getting User Input Via Keyboard--ref
ref:http://bash.cyberciti.biz/guide/Getting_User_Input_Via_Keyboard You can accept input from the ke ...
- I'm back
亲爱的博友们, 请忽略这一条, 这只是我个人的一个记录.
- JS中checkbox组件的使用
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...
- Android_listView_exc
listView布局: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" ...
- Docker中开启sshd服务
ssh服务安装 安装ssh服务 #yum install openssh-server -y 安装passwd(修改密码需要) #yum install passwd -y 修改sshd_config ...
- JUnit4注解基本介绍
@After If you allocate external resources in a Before method you need to release them after the test ...
- JavaScript入门(5)
一.什么是数组? 数组是一个值的集合,每一个值都有一个索引号,从0开始,每个索引都有一个相应的值,根据需要添加更多数值. 好比一个团,团里有很多人.如下使用数组存储5个学生成绩: 二.如何创建数组 使 ...