結果
| 問題 |
No.598 オーバーフローファンタジー
|
| コンテスト | |
| ユーザー |
kosakkun
|
| 提出日時 | 2017-11-24 22:34:45 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,238 bytes |
| コンパイル時間 | 844 ms |
| コンパイル使用メモリ | 82,100 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-26 01:38:28 |
| 合計ジャッジ時間 | 1,990 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <numeric>
#include <array>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;
ll N,X,A,B;
bool check1(long long x) {
ll t = X - x * A;
if (t <= 0) return true;
return false;
}
long long BinarySearchMin1(long long low, long long high) {
while (high - low > 1){
long long mid = (low + high) / 2;
if (check1(mid)) high = mid;
else low = mid;
}
return high;
}
bool check2(long long x) {
ll t = X + x * B;
if (t >= (1LL << (N - 1))) return true;
return false;
}
long long BinarySearchMin2(long long low, long long high) {
while (high - low > 1){
long long mid = (low + high) / 2;
if (check2(mid)) high = mid;
else low = mid;
}
return high;
}
int main() {
cin >> N >> X >> A >> B;
cout << min(BinarySearchMin1(0, 1LL << 31LL), BinarySearchMin2(0, 1LL << 31LL)) << endl;
return 0;
}
kosakkun