杭电ACM2010--水仙花数
水仙花数
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 268130 Accepted Submission(s): 75246
“水仙花数”是指一个三位数,它的各位数字的立方和等于其本身,比如:153=1^3+5^3+3^3。
现在要求输出所有在m和n范围内的水仙花数。
如果给定的范围内不存在水仙花数,则输出no;
每个测试实例的输出占一行。
300 380
370 371
#include<iostream>
using namespace std;
int main()
{
int a,b,c,num,i;
while(cin>>a>>b)
{
int d=,e=;
for(i=a;i<=b;i++)
{
num=i;
int sum=;
while(num)
{
c=num%;
num/=;
sum+=c*c*c;
}
if(sum==i)
{
if(e==)
{
e=;
cout<<i;
}
else cout<<" "<<i;
d=;
}
}
if(d==)cout<<"no";
cout<<endl;
}
return ;
}
杭电ACM2010--水仙花数的更多相关文章
- 杭电ACM水仙花数
水仙花数 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submi ...
- 杭电OJ2010---水仙花数(c++)(方法:输出几个数之间用空格隔开,最后一个数没有空格)
水仙花数 Problem Description 春天是鲜花的季节,水仙花就是其中最迷人的代表,数学上有个水仙花数,他是这样定义的: "水仙花数"是指一个三位数,它的各位数字的立方 ...
- 杭电ACM分类
杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...
- C语言 · 4-3水仙花数
问题描述 打印所有100至999之间的水仙花数.所谓水仙花数是指满足其各位数字立方和为该数字本身的整数,例如 153=1^3+5^3+3^3. 样例输入 一个满足题目要求的输入范例.例:无 样例输出 ...
- Java程序设计之打印100~999的水仙花数
package printDaffodilNumber; /* * 题目:打印出所有的"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身 ...
- acm入门 杭电1001题 有关溢出的考虑
最近在尝试做acm试题,刚刚是1001题就把我困住了,这是题目: Problem Description In this problem, your task is to calculate SUM( ...
- 51Nod--1015 水仙花数
51Nod: http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1015 1015 水仙花数 基准时间限制:1 秒 空间 ...
- js查找水仙花数
所谓水仙花数是满足类似于153=1³+5³+3³: 第一种方式:把这个数当做字符串来实现 <script> for(var i=100;i<=999;i++) { str_i=i.t ...
- 杭电acm 1002 大数模板(一)
从杭电第一题开始A,发现做到1002就不会了,经过几天时间终于A出来了,顺便整理了一下关于大数的东西 其实这是刘汝佳老师在<算法竞赛 经典入门 第二版> 中所讲的模板,代码原封不动写上的, ...
随机推荐
- [AtCoder3856]Ice Rink Game - 模拟
Problem Statement An adult game master and N children are playing a game on an ice rink. The game co ...
- oracle中文乱码问题解决
中文乱码问题解决:1.查看服务器端编码select userenv('language') from dual;我实际查到的结果为:AMERICAN_AMERICA.ZHS16GBK2.执行语句 se ...
- node.js Setup Wizard ended prematurely 安装失败
解决: 1. 按照管理员权限运行. 2.安装时禁用掉node 运行环境中的performance counters 和 ETW,或者可以尝试先禁用performance counters .
- aarch64的架构:unrecognized command line option '-mfpu=neon'
不用添加这个'-mfpu=neon'的编译器选项了,因为这个架构下neon是默认启动的. 参考: https://lists.linaro.org/pipermail/linaro-toolchain ...
- 约瑟夫环问题 --链表 C语言
总共有m个人在圆桌上,依次报名,数到第n个数的人退出圆桌,下一个由退出人下一个开始继续报名,循环直到最后一个停止将编号输出 #include <stdio.h>#include <s ...
- php.ini中文翻译版--转载
;;;;;;;; ; 警告 ; ;;;;;;;;;;; ; 此配置文件是对于新安装的PHP的默认设置. ; 默认情况下,PHP使用此配置文件安装 ; 此配置针对开发目的,并且*不是*针对生产环境 ; ...
- TensorFlow.org教程笔记(二) DataSets 快速入门
本文翻译自www.tensorflow.org的英文教程. tf.data 模块包含一组类,可以让你轻松加载数据,操作数据并将其输入到模型中.本文通过两个简单的例子来介绍这个API 从内存中的nump ...
- [Swift]LeetCode333. 最大的二分搜索子树 $ Largest BST Subtree
Given a binary tree, find the largest subtree which is a Binary Search Tree (BST), where largest mea ...
- [Swift]LeetCode829. 连续整数求和 | Consecutive Numbers Sum
Given a positive integer N, how many ways can we write it as a sum of consecutive positive integers? ...
- Docker 搭建pxc集群 + haproxy + keepalived 高可用(二)
上一节我们有了两个分片的pxc集群,这一节我们接着安装haproxy和keepalived的实现集群的高可用 一.先下载haproxy的镜像 [root@localhost ~]# docker pu ...