HDU 2010

来源:互联网 发布:c语言预处理指令应用 编辑:程序博客网 时间:2024/06/05 19:50

今天只刷了一道题目,并不是说不想刷了,只是想留一点时间去看一下 mit 算法导论课程,总共有23集,准备花一个多月的时间去看完这部经典的视频,我也买了配套这个视频的书本,很厚。慢慢看吧,准备花1年的时间慢慢研究。不求快只求理解。推荐大家可以看一下。据视频中说每天不懈的编写代码两年+学习算法导论这门课等价于每天编写代码并维持10年的效果。以下是今天解题过程


HDU 2010

 /* THE PROGRAM IS MADE BY SH *//*--------------------------------------------------------------------------- *       http://acm.hdu.edu.cn/showproblem.php?pid=2010 *       水仙花数 *       Date  : 2015/4/23----------------------------------------------------------------------------*/#include <algorithm>#include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <cmath>#include <ctime>using namespace std;int main(){  int c[3] = {0, 0, 0 };  int m,n;  int index = 0,temp = 0;  int d[1000] = {0};   while(scanf("%d%d", &m,&n) != EOF && m <= n && n <= 999 && m >= 100){           for(int i = m; i <= n; ++i){          c[0] = i/100%10;          c[1] = i/10%10;          c[2] = i%10;          if(i == c[0]*c[0]*c[0]+c[1]*c[1]*c[1]+c[2]*c[2]*c[2]){              d[ index ] = i;              ++ index;          }       }       for(int i = 0; i <index; ++i){           printf("%d",d[i]);           if(i != index-1){           printf(" ");           }            else printf("\n");       }       if( index == 0){           printf("no\n");       }       index = 0;  }  system("Pause");  return 0;}


0 0
原创粉丝点击