結果
| 問題 |
No.281 門松と魔法(1)
|
| コンテスト | |
| ユーザー |
kurenai3110
|
| 提出日時 | 2016-06-14 18:57:34 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 885 bytes |
| コンパイル時間 | 528 ms |
| コンパイル使用メモリ | 64,404 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-06 19:56:21 |
| 合計ジャッジ時間 | 2,026 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 39 WA * 18 |
ソースコード
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
int out(long int i){
cout << i << endl;
return 0;
}
int main()
{
long int d, h1, h2, h3;
long int cnt;
cin >> d >> h1 >> h2 >> h3;
if (h2 >= h1&&h2 <= h3 || h2<=h1&&h2>=h3){
if (d == 0){
return out(-1);
}
if ((h1 == h2 || h2 == h3)&&min(h1,h3)==0){
return out(-1);
}
if (h1 == h3&&floor(h1 / d) == 1){
return out(-1);
}
if (h2 <= d){
if (h2!= 0){
if (max(h1, h3) % d == 0) return out(-1);
return out(max(h1, h3) / d + ceil((max(h1,h3) % d) / d));
}
return out(-1);
}
if (h3 - h2 >= h2 - h1){
return out((h2 - h1) / d + 1);
}
else if (h3 - h2 < h2 - h1){
return out((h3 - h2) / d +1);
}
}
else{
if (h3 == h1){
if (h1==0) return out(-1);
else return out(1);
}
return out(0);
}
return 0;
}
kurenai3110