HDU 2010 水仙花數
阿新 • • 發佈:2018-12-17
#include<stdio.h> #include <malloc.h> #include <math.h> #include <stdbool.h> int main(){ int m=0,n=0; while(scanf("%d %d",&m,&n)!= EOF){ int count = 0; for(int i=m;i<=n;i++){ int t = i; int sum = 0; while(t) { int t2 = t%10; sum += t2 * t2 * t2; t /=10; } if(sum == i){ if(count > 0){ printf(" "); } printf("%d",i); count++; } } if(count == 0){ printf("no"); } printf("\n"); } return 0; }