結果
問題 |
No.375 立方体のN等分 (1)
|
ユーザー |
![]() |
提出日時 | 2016-07-15 22:10:36 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 118 ms / 5,000 ms |
コード長 | 763 bytes |
コンパイル時間 | 445 ms |
コンパイル使用メモリ | 61,620 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-15 01:18:50 |
合計ジャッジ時間 | 1,827 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 32 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:24:38: warning: ‘c’ may be used uninitialized in this function [-Wmaybe-uninitialized] 24 | ans = min(ans, a + b + c - 3); | ~~~~~~^~~ main.cpp:24:34: warning: ‘b’ may be used uninitialized in this function [-Wmaybe-uninitialized] 24 | ans = min(ans, a + b + c - 3); | ~~^~~
ソースコード
#include <iostream> #include <algorithm> #include <cmath> #include <cstdio> using namespace std; typedef long long ll; #define rep(i,n) for(int i=0;i<(n);i++) const ll INF = 1e16; int main(void){ ll n; cin >> n; ll tmp = n; ll a, b, c, ans = INF; for (ll i = 1; i <= pow((double)n + 1, 1.0 / 3.0); ++i){ if(n % i == 0){ a = i; n /= a; for (ll j = 1; j <= sqrt((double)n) + 1; ++j){ if(n % j == 0){ b = j; c = n / j; } ans = min(ans, a + b + c - 3); // printf("%lld %lld %lld\n", a, b, c); } } n = tmp; } printf("%lld %lld\n", ans, tmp - 1); return 0; }