#include <stdio.h> #include <string.h> #define MAX_DIGITS 50 // 各要素に格納する最大桁数 #define MAX_EXPONENT 99 void power3(unsigned long result[]) { result[0] = 1; // 3^0 = 1 for (int i = 1; i <= MAX_EXPONENT; i++) { for (int j = 0; j < MAX_DIGITS; j++) { result[j] *= 3; } for (int j = 0; j < MAX_DIGITS; j++) { if (result[j] >= 10000000) { // 7桁を超えた場合の繰り上げ処理 result[j + 1] += result[j] / 10000000; result[j] %= 10000000; } } } } void print_result(unsigned long result[]) { for (int i = 1; i <= MAX_EXPONENT; i++) { int start = MAX_DIGITS - 1; while (start > 0 && result[start] == 0) { start--; } for (int j = start - 1; j >= 0; j--) { } } } int main() { unsigned long result[MAX_DIGITS] = {0}; power3(result); print_result(result); return 0; }
Standard input is empty
3^1 = 171792506910670443678820376588540424234035840667 3^2 = 171792506910670443678820376588540424234035840667 3^3 = 171792506910670443678820376588540424234035840667 3^4 = 171792506910670443678820376588540424234035840667 3^5 = 171792506910670443678820376588540424234035840667 3^6 = 171792506910670443678820376588540424234035840667 3^7 = 171792506910670443678820376588540424234035840667 3^8 = 171792506910670443678820376588540424234035840667 3^9 = 171792506910670443678820376588540424234035840667 3^10 = 171792506910670443678820376588540424234035840667 3^11 = 171792506910670443678820376588540424234035840667 3^12 = 171792506910670443678820376588540424234035840667 3^13 = 171792506910670443678820376588540424234035840667 3^14 = 171792506910670443678820376588540424234035840667 3^15 = 171792506910670443678820376588540424234035840667 3^16 = 171792506910670443678820376588540424234035840667 3^17 = 171792506910670443678820376588540424234035840667 3^18 = 171792506910670443678820376588540424234035840667 3^19 = 171792506910670443678820376588540424234035840667 3^20 = 171792506910670443678820376588540424234035840667 3^21 = 171792506910670443678820376588540424234035840667 3^22 = 171792506910670443678820376588540424234035840667 3^23 = 171792506910670443678820376588540424234035840667 3^24 = 171792506910670443678820376588540424234035840667 3^25 = 171792506910670443678820376588540424234035840667 3^26 = 171792506910670443678820376588540424234035840667 3^27 = 171792506910670443678820376588540424234035840667 3^28 = 171792506910670443678820376588540424234035840667 3^29 = 171792506910670443678820376588540424234035840667 3^30 = 171792506910670443678820376588540424234035840667 3^31 = 171792506910670443678820376588540424234035840667 3^32 = 171792506910670443678820376588540424234035840667 3^33 = 171792506910670443678820376588540424234035840667 3^34 = 171792506910670443678820376588540424234035840667 3^35 = 171792506910670443678820376588540424234035840667 3^36 = 171792506910670443678820376588540424234035840667 3^37 = 171792506910670443678820376588540424234035840667 3^38 = 171792506910670443678820376588540424234035840667 3^39 = 171792506910670443678820376588540424234035840667 3^40 = 171792506910670443678820376588540424234035840667 3^41 = 171792506910670443678820376588540424234035840667 3^42 = 171792506910670443678820376588540424234035840667 3^43 = 171792506910670443678820376588540424234035840667 3^44 = 171792506910670443678820376588540424234035840667 3^45 = 171792506910670443678820376588540424234035840667 3^46 = 171792506910670443678820376588540424234035840667 3^47 = 171792506910670443678820376588540424234035840667 3^48 = 171792506910670443678820376588540424234035840667 3^49 = 171792506910670443678820376588540424234035840667 3^50 = 171792506910670443678820376588540424234035840667 3^51 = 171792506910670443678820376588540424234035840667 3^52 = 171792506910670443678820376588540424234035840667 3^53 = 171792506910670443678820376588540424234035840667 3^54 = 171792506910670443678820376588540424234035840667 3^55 = 171792506910670443678820376588540424234035840667 3^56 = 171792506910670443678820376588540424234035840667 3^57 = 171792506910670443678820376588540424234035840667 3^58 = 171792506910670443678820376588540424234035840667 3^59 = 171792506910670443678820376588540424234035840667 3^60 = 171792506910670443678820376588540424234035840667 3^61 = 171792506910670443678820376588540424234035840667 3^62 = 171792506910670443678820376588540424234035840667 3^63 = 171792506910670443678820376588540424234035840667 3^64 = 171792506910670443678820376588540424234035840667 3^65 = 171792506910670443678820376588540424234035840667 3^66 = 171792506910670443678820376588540424234035840667 3^67 = 171792506910670443678820376588540424234035840667 3^68 = 171792506910670443678820376588540424234035840667 3^69 = 171792506910670443678820376588540424234035840667 3^70 = 171792506910670443678820376588540424234035840667 3^71 = 171792506910670443678820376588540424234035840667 3^72 = 171792506910670443678820376588540424234035840667 3^73 = 171792506910670443678820376588540424234035840667 3^74 = 171792506910670443678820376588540424234035840667 3^75 = 171792506910670443678820376588540424234035840667 3^76 = 171792506910670443678820376588540424234035840667 3^77 = 171792506910670443678820376588540424234035840667 3^78 = 171792506910670443678820376588540424234035840667 3^79 = 171792506910670443678820376588540424234035840667 3^80 = 171792506910670443678820376588540424234035840667 3^81 = 171792506910670443678820376588540424234035840667 3^82 = 171792506910670443678820376588540424234035840667 3^83 = 171792506910670443678820376588540424234035840667 3^84 = 171792506910670443678820376588540424234035840667 3^85 = 171792506910670443678820376588540424234035840667 3^86 = 171792506910670443678820376588540424234035840667 3^87 = 171792506910670443678820376588540424234035840667 3^88 = 171792506910670443678820376588540424234035840667 3^89 = 171792506910670443678820376588540424234035840667 3^90 = 171792506910670443678820376588540424234035840667 3^91 = 171792506910670443678820376588540424234035840667 3^92 = 171792506910670443678820376588540424234035840667 3^93 = 171792506910670443678820376588540424234035840667 3^94 = 171792506910670443678820376588540424234035840667 3^95 = 171792506910670443678820376588540424234035840667 3^96 = 171792506910670443678820376588540424234035840667 3^97 = 171792506910670443678820376588540424234035840667 3^98 = 171792506910670443678820376588540424234035840667 3^99 = 171792506910670443678820376588540424234035840667