結果

問題 No.499 7進数変換
ユーザー Yasufu12
提出日時 2017-04-07 22:54:17
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 345 bytes
コンパイル時間 418 ms
コンパイル使用メモリ 59,516 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-16 02:48:08
合計ジャッジ時間 1,296 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <math.h>

using namespace std;

long long n, num = 0, ans = 0, box = 0, b2 = 0;

int main(){
	cin >> n;

	while (n >= pow(7, num)){
		num++;
	}

	for (int i = num; i >= 0; i--){
		box = pow(7, i);

		b2 = n / box;
		if (n >= box){
			ans += b2 * pow(10, i);
		}
		n = n % box;
	}

	cout << ans << endl;

	return 0;
}
0