尋找水仙花數
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
int i = 0;
int a = 0;
for (i = 100; i < 1000; i++)
{
a = pow(i / 100, 3.0) + pow(i % 100 / 10, 3.0) + pow(i % 10, 3.0);
if(a == i)
printf("%d ", i);
}
system("pause");
return 0;
}
相關推薦
尋找水仙花數
#include <stdio.h> #include <stdlib.h> #include <math.h> int main() { int i = 0; int a = 0; for (i = 100; i < 1000; i++)
java 尋找水仙花數
true int image -s mage size class oid 分解 題目:打印出所有的"水仙花數",所謂"水仙花數"是指一個三位數,其各位數字立方和等於該數本身。例如:153是一個"水仙花數",因為153=1的三次方+5的三次方+3的三次方。 程序分析:利用
使用PHP實現水仙花數及各種特殊有趣數的輸出
php 水仙花數 特殊數據 有趣 算法尊敬的讀者,見文好。本文包含以下內容:1,為什麽要寫這篇文章!2,具體的方案及代碼實現!3,你可能遇到的問題!4,文末本文測試用源碼網盤地址!特殊說明:本文使用的語言是PHP;本文運行的環境是:Apache2.4, PHP5.6 。第一部分:為什麽要寫這篇文章!因為經常會
篩選水仙花數
int () %d tdi pri 水仙花 輸出 ret for //水仙花數--個位的平方+十位的平方+百位的平方(等於==)該三位數 #include<stdio.h>int main(){ int ge,shi,bai; //從100開始篩選for(i
51Nod 1015 水仙花數
efi bre clu mes long bsp long long cout pan 水仙花數是指一個 n 位數 ( n >= 3 ),它的每個位上的數字的 n 次冪之和等於它本身。(例如:1^3 + 5^3 + 3^3 = 153) 給出一個整數M,求 &g
HDU 1058 Humble Numbers (動規+尋找醜數問題)
string ffi 找規律 得到 mar lan algorithm size cep Humble Numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (J
數列和+水仙花數+句子翻轉
split() span map sflow flow img isf -1 blog 1、數列和 import math m,n = map(int, raw_input().split()) answer = [] for i in range(n): ans
水仙花數
一個 pri code bsp 位數 取出 args pre class 水仙花數,又稱為阿姆斯特朗數,水仙花數是指一個 n 位數(n≥3 ),它的每個位上的數字的 n 次冪之和等於它本身(例如:1^3 + 5^3+ 3^3 = 153)。 使用Java編寫一個水仙花數且
C語言——求水仙花數
printf 余數 body 位與 number 水仙花 一次 語言 是否 昨天,雷老師偶有閑致,評講了n周前的C程序設計作業。其中講到了一到求水仙花數的題,給出了一種漂亮的算法,在此記錄下來。 原題 輸出所有的水仙花數,所謂水仙花數是指一個3位數,其各位數字立方和等於該數
[LeetCode]501. Find Mode in Binary Search Tree二叉搜索樹尋找眾數
pri fin lis 需要 efi lee value spa find 這次是二叉搜索樹的遍歷 感覺只要和二叉搜索樹的題目,都要用到一個重要性質: 中序遍歷二叉搜索樹的結果是一個遞增序列; 而且要註意,在遞歸遍歷樹的時候,有些參數如果是要隨遞歸不斷更新(也就是如果遞歸返
Python小代碼_9_求水仙花數
pos == body post end for print color 代碼 for i in range(100, 1000): ge = i % 10 shi = i // 10 % 10 bai = i // 100 if ge *
cf166e 在四面體上尋找路線數 遞推,取模
lac cti limit self pie code pri esp AD 來源:codeforces E. Tetrahedron You are given a tetrahedron. Let‘s mark it
1015 水仙花數問題(51Nod)
示例 圖片 時間 nod arraylist sys true 它的 output 1015 水仙花數 基準時間限制:1 秒 空間限制:131072 KB 分值: 5 難度:1級算法題 水仙花數是指一個 n 位數 ( n >= 3 ),它的每個位上的數字的 n
java代碼:用for循環求和,求偶數和,求奇數和,打印水仙花數,統計水仙花數
java代碼 for循環 求和 打印水仙花數統計水仙花 用for循環求和,求偶數和,求奇數和,打印水仙花數,統計水仙花數package loop; public class For1 {public static void main(String[] args) {int sum=0;for(
用c#語言編寫水仙花數
sta program for eric eap write 水仙花 ogr ati using System;using System.Collections.Generic;using System.Linq;using System.Text;using System
JS 1000以內的水仙花數 (三位數 各個數字的立方和等於本身 例如 1*1*1 + 5*5*5 + 7*7*7 = 157)
script document class AC pan code type ctype ava <!DOCTYPE html> <html> <head> <meta charset="UTF-8">
使用JS打印水仙花數
AS 特殊 AI 就是 write 它的 clas 三位數 parseint /* 水仙花數是一種特殊的三位數,它的特點就是,每個數位的立方和,等於它本身。 比如 153 就是水仙花數。因為: 13+53 +33 = 153 100~999 之內,
51nod 1016 水仙花數
pan click spl for nbsp cmp mat img ide 大水仙花數模板+1…… #include<stdio.h> #include<math.h> #include<queue&
用js寫水仙花數
amp == 位數 等於 parse lse div 就是 () ...js //輸入一個三位數,水仙花數就是個位的三次方+十為的三次方+百位的三次方之和等於本身 console.log(‘請輸入一個三位數:‘); let a = readline.question(
練習題5:水仙花數
ont utf-8 title PE 水仙花 立方和 rst 春天 解法 題目描述 春天是鮮花的季節,水仙花就是其中最迷人的代表,數學上有個水仙花數,他是這樣定義的: “水仙花數”是指一個三位數,它的各位數字的立方和等於其本身,比如:153=1^3+5^3+3^3。 現在