結果
問題 | No.48 ロボットの操縦 |
ユーザー | kai10920 |
提出日時 | 2023-01-25 18:34:12 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 796 bytes |
コンパイル時間 | 392 ms |
コンパイル使用メモリ | 31,616 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-26 21:34:43 |
合計ジャッジ時間 | 1,248 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
#include<stdio.h> int walk(int to,int l){ if(to%l==0){ return to/l; }else{ return to/l+1; } } int main(){ int x; int y; int l; scanf("%d%d%d",&x,&y,&l); int step=0; if(y>0){ step+=walk(y,l); if(x>0){ step++; step+=walk(x,l); }else if(x<0){ step++; step+=walk(-x,l); } }else if(y<0){ step++; if(x>0){ step+=walk(x,l); }else if(x<0){ step+=walk(-x,l); } step++; step+=walk(-y,l); }else{ if(x>0){ step++; step+=walk(x,l); }else if(x<0){ step++; step+=walk(-x,l); } } printf("%d",step); }