解题思路:
试了一下快速幂,真香
注意事项:
参考代码:
#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语言程序设计教程(第三版)课后习题6.8 (C语言代码)浏览:527 |
【明明的随机数】 (C语言代码)浏览:787 |
1025题解浏览:738 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:561 |
C语言程序设计教程(第三版)课后习题6.2 (C语言代码)浏览:540 |
C语言程序设计教程(第三版)课后习题9.8 (C语言代码)浏览:616 |
整数平均值 (C语言代码)浏览:786 |
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)浏览:474 |
C语言程序设计教程(第三版)课后习题7.5 (C语言代码)浏览:554 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:561 |