結果

問題 No.499 7進数変換
ユーザー syuki791syuki791
提出日時 2017-07-02 16:19:46
言語 Java21
(openjdk 21)
結果
AC  
実行時間 135 ms / 1,000 ms
コード長 572 bytes
コンパイル時間 2,636 ms
コンパイル使用メモリ 75,184 KB
実行使用メモリ 41,628 KB
最終ジャッジ日時 2024-04-15 12:35:19
合計ジャッジ時間 7,963 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
41,436 KB
testcase_01 AC 129 ms
41,200 KB
testcase_02 AC 130 ms
41,160 KB
testcase_03 AC 130 ms
41,196 KB
testcase_04 AC 129 ms
41,360 KB
testcase_05 AC 130 ms
41,320 KB
testcase_06 AC 132 ms
41,464 KB
testcase_07 AC 131 ms
41,628 KB
testcase_08 AC 116 ms
40,400 KB
testcase_09 AC 129 ms
41,316 KB
testcase_10 AC 131 ms
41,320 KB
testcase_11 AC 132 ms
41,300 KB
testcase_12 AC 131 ms
41,396 KB
testcase_13 AC 135 ms
41,280 KB
testcase_14 AC 134 ms
41,380 KB
testcase_15 AC 132 ms
41,392 KB
testcase_16 AC 131 ms
41,420 KB
testcase_17 AC 131 ms
41,108 KB
testcase_18 AC 132 ms
41,044 KB
testcase_19 AC 133 ms
41,280 KB
testcase_20 AC 132 ms
41,392 KB
testcase_21 AC 132 ms
41,532 KB
testcase_22 AC 132 ms
41,404 KB
testcase_23 AC 115 ms
40,016 KB
testcase_24 AC 130 ms
41,276 KB
testcase_25 AC 129 ms
41,264 KB
testcase_26 AC 128 ms
41,564 KB
testcase_27 AC 118 ms
40,116 KB
testcase_28 AC 131 ms
41,116 KB
testcase_29 AC 131 ms
41,076 KB
testcase_30 AC 130 ms
41,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.Stack;

public class Main {
	
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		String str = s.next();
		s.close();
		
		long l = Long.parseLong(str);
		long ltmp = l;
		Stack<Long> stack = new Stack<Long>();
		
		while(true){			
			stack.push(ltmp%7);
			if(ltmp/7 < 7){
				stack.push(ltmp/7);
				break;
			}
			ltmp = ltmp/7;
		}
		long ans = 0;
		long pow = stack.size()-1;
		while(!stack.empty()){
			ans += stack.pop()* (long)Math.pow(10, pow);
			pow--;
		}
		System.out.println(ans);
	}

}
0