#include <stdio.h>
#include <string.h>
#define MAX_DIGITS 50 // 必要な桁数に応じて調整
void power3(unsigned long result[]) {
unsigned long carry = 0;
for (int i = 0; i < MAX_DIGITS; i++) {
unsigned long temp = result[i] * 3 + carry;
result[i] = temp % 10000000; // 7桁の整数に分割
carry = temp / 10000000;
}
}
void print_result(unsigned long result[]) {
int start = MAX_DIGITS - 1;
while (start > 0 && result[start] == 0) {
start--;
}
for (int i = start - 1; i >= 0; i--) {
printf("%07lu", result
[i
]); // 7桁で表示 }
}
int main() {
unsigned long result[MAX_DIGITS];
memset(result
, 0, sizeof(result
)); result[0] = 1; // 3の0乗は1
for (int i = 1; i <= 99; i++) {
power3(result);
print_result(result);
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KCiNkZWZpbmUgTUFYX0RJR0lUUyA1MCAvLyDlv4XopoHjgarmoYHmlbDjgavlv5zjgZjjgaboqr/mlbQKCnZvaWQgcG93ZXIzKHVuc2lnbmVkIGxvbmcgcmVzdWx0W10pIHsKICAgIHVuc2lnbmVkIGxvbmcgY2FycnkgPSAwOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBNQVhfRElHSVRTOyBpKyspIHsKICAgICAgICB1bnNpZ25lZCBsb25nIHRlbXAgPSByZXN1bHRbaV0gKiAzICsgY2Fycnk7CiAgICAgICAgcmVzdWx0W2ldID0gdGVtcCAlIDEwMDAwMDAwOyAvLyA35qGB44Gu5pW05pWw44Gr5YiG5YmyCiAgICAgICAgY2FycnkgPSB0ZW1wIC8gMTAwMDAwMDA7CiAgICB9Cn0KCnZvaWQgcHJpbnRfcmVzdWx0KHVuc2lnbmVkIGxvbmcgcmVzdWx0W10pIHsKICAgIGludCBzdGFydCA9IE1BWF9ESUdJVFMgLSAxOwogICAgd2hpbGUgKHN0YXJ0ID4gMCAmJiByZXN1bHRbc3RhcnRdID09IDApIHsKICAgICAgICBzdGFydC0tOwogICAgfQogICAgcHJpbnRmKCI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