結果
| 問題 |
No.281 門松と魔法(1)
|
| コンテスト | |
| ユーザー |
alpha_virginis
|
| 提出日時 | 2015-09-18 22:52:46 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,338 bytes |
| コンパイル時間 | 1,288 ms |
| コンパイル使用メモリ | 157,820 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-06 18:50:52 |
| 合計ジャッジ時間 | 3,092 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 WA * 42 RE * 3 |
ソースコード
#include <bits/stdc++.h>
#include <cstdint>
#include <sys/time.h>
typedef std::int_fast32_t s32;
typedef std::uint_fast32_t u32;
typedef std::int_fast64_t s64;
typedef std::uint_fast64_t u64;
const unsigned long mod = 1000000007;
const double EPS = 0.00000001;
const int INF = (1 << 29);
typedef std::pair<int, int> P;
template<typename T>
void print_array(T *A_, s32 size) {
printf("%d\n", size);
if( size != 0 ) {
for(int i = 0; i < size - 1; ++i) {
printf("%d ", A_[i]);
}
printf("%d\n", A_[size - 1]);
}
}
int d;
int a, b, c;
int p1(void) {
if( a == 0 or c == 0 ) return INF;
if( a < b and c < b ) return 0;
if( (b - std::min(a, c)) % d == 0 ) return (b - std::min(a, c)) / d + 1;
return (b - std::min(a, c)) / d;
}
int p2(void) {
if( b == 0 ) return INF;
if( a < b and c < b ) return 0;
int res = 0;
if( c > b ) {
if( (c - b) % d == 0 ) res += (c - b) / d + 1;
else res += (c - b) / d;
}
if( a > b ) {
if( (a - b) % d == 0 ) res += (a - b) / d + 1;
else res += (a - b) / d;
}
return res;
}
int main() {
std::cin >> d;
std::cin >> a >> b >> c;
int res = INF;
res = std::min(res, p1());
res = std::min(res, p2());
if( res == INF ) res = -1;
std::cout << res << std::endl;
//std::cout << p1() << " " << p2() << std::endl;
return 0;
}
alpha_virginis