結果
| 問題 |
No.1176 少ない質問
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-21 21:52:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 816 bytes |
| コンパイル時間 | 582 ms |
| コンパイル使用メモリ | 70,784 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-15 05:33:37 |
| 合計ジャッジ時間 | 1,304 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 |
ソースコード
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(){
long long A;
cin >> A;
long long cnt = 0, cnt2 = 0;
long long t = A;
long long temp1 = 1;
long long c = 0;
while(A > temp1){
temp1 *= 2;
c++;
if(A == temp1){
cout << c * 2 << endl;
return 0;
}
}
temp1 = 1;
c = 0;
while(A > temp1){
temp1 *= 3;
c++;
if(A == temp1){
cout << c * 3 << endl;
return 0;
}
}
if(A == 5){
cout << 5 << endl;
return 0;
}
while(t > 0){
t /= 2;
cnt++;
}
long long t1 = cnt * 2;
while(A > 0){
A /= 3;
cnt2++;
}
long long t2 = cnt2 * 3;
cout << min(t1, t2) << endl;
}