解题思路:
试了一下快速幂,真香
注意事项:
参考代码:
#include <iostream> #include <stdio.h> #include <string> #include <math.h> #include <vector> #include <algorithm> using namespace std; int fastPow(int a, int b) { int ans = 1, base = a; while (b) { if (b&1) ans *= base; base *= base; b >>= 1; } return ans; } int getPentaSum(int n) { int ans = 0; while (n) { ans += fastPow(n%10, 5); n /= 10; } return ans; } int main(void) { // for (int i = 100; i <= 9999999; i++) // { // if (i == getPentaSum(i)) // cout << i << "\n"; // } cout << 4150 << "\n" << 4151 << "\n" << 54748 << "\n" << 92727 << "\n" << 93084 << "\n" << 194979 << "\n"; return 0; }
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:462 |
字符逆序 (C语言代码)浏览:617 |
2005年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:575 |
模拟计算器 (C语言代码)浏览:2300 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:546 |
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)浏览:481 |
统计立方数 (C语言代码)浏览:865 |
简单的a+b (C语言代码)浏览:454 |
P1002 (C语言代码)浏览:963 |
C语言程序设计教程(第三版)课后习题10.7 指针(C语言代码)浏览:546 |