"HDU 2010" Narcissus number

Source: Internet
Author: User

http://acm.hdu.edu.cn/showproblem.php?pid=2010

Spring is the season of flowers, Narcissus is one of the most charming representatives, there is a number of daffodils in mathematics, he is defined as: "Narcissus number" refers to a three-digit number, its number of the cubic and equal to itself, such as: 153=1^3+5^3+3^3. It is now required to output all the number of daffodils in the M and N ranges.

Solution: Narcissus number, also known as Armstrong number, there is no direct rule, only violent solution.

A limited number of series, play the table (lazy write violence)

Use the online algorithm to make large tables:

1:1, 2, 3, 4, 5, 6, 7, 8, 93:153, 370, 371, 4,074:1634, 8208, 9474
5:54,748, 92727, 930846:5488347:1741725, 4210818, 9800817, 99,263,158:24,678,050, 24678051, 885,934,779:146,511,208, 472335975 , 534494836, 91,298,515,310:4,679,307,774, 3216404965011:4002839422511:4267829060311:4938855060611:3216404965111: 9420459191411:4470863567911:8269391657814:2811644033596716:433828176939137016:433828176939137117: 2189714258761207517:3564159420896413217:3587569906225003519:151784154330750503919:328958298444318703219: 492927388592808882619:449812879116462486920:6310542598859969391621:44917739914603869730721: 12846864304373139125223:2790786500997705256781423:3545259010403169193594323:2787969489305407447140523: 2188769684112291628885824:17408800593806529302372224:188451485447897896036875.: Finite sequence, Total 88 Last 115132219018763992565095597973971522401
//This file was made by yjinpeng,created by Xuyike ' s black technology automatically.//Copyright (C) Changjun High School, Inc.//I don ' t know.#include<iostream>#include<cstdio>using namespacestd;inta[Ten]={153,370,371,407},b[Ten];intMain () {Freopen ("2010.in","R", stdin); Freopen ("2010.out","W", stdout); intL,r,flag;  while(~SCANF ("%d%d",&l,&R)) {Flag=0;  for(intI=0;i<4; i++)            if(a[i]>=l&&a[i]<=r) b[++flag]=A[i]; if(flag) { for(intI=1; i<flag;i++) printf ("%d", B[i]);p rintf ("%d", B[flag]);} Elseprintf"No");p rintf ("\ n"); }    return 0;}

"HDU 2010" Narcissus number

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.