結果

問題 No.1176 少ない質問
ユーザー pengin_2000pengin_2000
提出日時 2021-08-29 18:41:54
言語 C
(gcc 12.3.0)
結果
TLE  
実行時間 -
コード長 678 bytes
コンパイル時間 1,527 ms
コンパイル使用メモリ 29,184 KB
実行使用メモリ 15,424 KB
最終ジャッジ日時 2024-05-01 23:19:35
合計ジャッジ時間 4,957 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:2:15: warning: conflicting types for built-in function 'pow'; expected 'double(double,  double)' [-Wbuiltin-declaration-mismatch]
    2 | long long int pow(long long int a, long long int n)
      |               ^~~
main.c:2:1: note: 'pow' is declared in header '<math.h>'
    1 | #include<stdio.h>
  +++ |+#include <math.h>
    2 | long long int pow(long long int a, long long int n)

ソースコード

diff #

#include<stdio.h>
long long int pow(long long int a, long long int n)
{
	long long int res = 1;
	while (n > 0)
	{
		if (n % 2 > 0)
			res = res * a;
		a = a * a;
		n /= 2;
	}
	return res;
}
long long int root(long long int a, long long int n)
{
	long long int min, mid, max;
	min = 0;
	max = 1;
	while (pow(max, n) < a)
		max *= 2;
	while (max - min > 1)
	{
		mid = (max + min) / 2;
		if (pow(mid, n) < a)
			min = mid;
		else
			max = mid;
	}
	return max;
}
int main()
{
	long long int a;
	scanf("%lld", &a);
	long long int i, ans = a, r;
	for (i = 2;; i++)
	{
		r = root(a, i);
		if (ans > r * i)
			ans = r * i;
		if (r == 2)
			break;
	}
	printf("%lld\n", ans);
	return 0;
}
0