結果

問題 No.1700 floor X
ユーザー ks2mks2m
提出日時 2021-10-08 21:51:36
言語 Java21
(openjdk 21)
結果
AC  
実行時間 436 ms / 2,000 ms
コード長 853 bytes
コンパイル時間 2,705 ms
コンパイル使用メモリ 73,856 KB
実行使用メモリ 61,536 KB
最終ジャッジ日時 2023-09-16 08:55:22
合計ジャッジ時間 22,337 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,736 KB
testcase_01 AC 392 ms
60,428 KB
testcase_02 AC 393 ms
60,528 KB
testcase_03 AC 387 ms
60,416 KB
testcase_04 AC 386 ms
60,292 KB
testcase_05 AC 382 ms
60,224 KB
testcase_06 AC 381 ms
60,304 KB
testcase_07 AC 389 ms
60,736 KB
testcase_08 AC 392 ms
60,284 KB
testcase_09 AC 396 ms
61,068 KB
testcase_10 AC 385 ms
60,276 KB
testcase_11 AC 386 ms
60,224 KB
testcase_12 AC 381 ms
60,484 KB
testcase_13 AC 392 ms
60,292 KB
testcase_14 AC 375 ms
60,336 KB
testcase_15 AC 383 ms
60,568 KB
testcase_16 AC 387 ms
60,776 KB
testcase_17 AC 375 ms
60,216 KB
testcase_18 AC 384 ms
60,440 KB
testcase_19 AC 387 ms
60,532 KB
testcase_20 AC 376 ms
60,580 KB
testcase_21 AC 427 ms
60,908 KB
testcase_22 AC 419 ms
60,136 KB
testcase_23 AC 421 ms
60,488 KB
testcase_24 AC 433 ms
60,484 KB
testcase_25 AC 426 ms
61,080 KB
testcase_26 AC 404 ms
60,504 KB
testcase_27 AC 422 ms
60,348 KB
testcase_28 AC 433 ms
60,656 KB
testcase_29 AC 408 ms
61,092 KB
testcase_30 AC 426 ms
60,440 KB
testcase_31 AC 411 ms
60,612 KB
testcase_32 AC 420 ms
60,460 KB
testcase_33 AC 409 ms
60,444 KB
testcase_34 AC 414 ms
60,368 KB
testcase_35 AC 418 ms
59,056 KB
testcase_36 AC 403 ms
61,536 KB
testcase_37 AC 423 ms
60,480 KB
testcase_38 AC 428 ms
60,796 KB
testcase_39 AC 436 ms
60,256 KB
testcase_40 AC 416 ms
60,460 KB
testcase_41 AC 416 ms
61,076 KB
testcase_42 AC 125 ms
55,944 KB
testcase_43 AC 422 ms
60,424 KB
testcase_44 AC 414 ms
58,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		for (int z = 0; z < t; z++) {
			long n = sc.nextLong();
			System.out.println(root(n, 2));
		}
		sc.close();
	}

	static int root(long x, int n) {
		int ng = 1000000001;
		int ok = 1;
		while (ng - ok > 1) {
			int mid = (ok + ng) / 2;
			if (Math.pow(mid, n) < Long.MAX_VALUE) {
				ok = mid;
			} else {
				ng = mid;
			}
		}
		ng = ok + 1;
		ok = 1;
		while (ng - ok > 1) {
			int mid = (ok + ng) / 2;
			if (power(mid, n) <= x) {
				ok = mid;
			} else {
				ng = mid;
			}
		}
		return ok;
	}

	static long power(long x, long n) {
		if (n == 0) {
			return 1;
		}
		long val = power(x, n / 2);
		val = val * val;
		if (n % 2 == 1) {
			val = val * x;
		}
		return val;
	}
}
0