結果
| 問題 |
No.281 門松と魔法(1)
|
| コンテスト | |
| ユーザー |
184
|
| 提出日時 | 2015-09-21 02:56:51 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 1,000 ms |
| コード長 | 487 bytes |
| コンパイル時間 | 151 ms |
| コンパイル使用メモリ | 23,808 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-06 20:29:23 |
| 合計ジャッジ時間 | 1,567 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 57 |
コンパイルメッセージ
main.cpp: In function ‘I main()’:
main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | scanf("%d%d%d%d",&d,&a,&b,&c);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <cstdio>
//namaega184
typedef int I;
I d,a,b,c,o=1e9,n=1e9,t,x,y;
#define s(a,b,c) c?a>b?a:b:a<b?a:b
#define r return
I f(I &a,I b){I m=(a-b+d)/d;a=s(0,a-d*m,1);r m;}
I k(){r (b>a&b>c|b<a&b<c)&a!=c;}
I main(){
scanf("%d%d%d%d",&d,&a,&b,&c);
if(!d){puts(k()?"0":"-1"); r 0;}
x=a,y=c,t=0;
if(x>=b)t+=f(x,b);if(b<=y)t+=f(y,b);if(x==y)t+=f(x,y);if(x!=y)o=s(o,t,0);
x=b,y=s(a,c,0),t=0;
if(a==c)t+=f(y,a);if(x>=y)t+=f(x,y);if(x!=y)o=s(o,t,0);
printf("%d\n",o<n?o:-1);
r 0;
}
184