結果

問題 No.48 ロボットの操縦
ユーザー IRXGCGySDjxVBhf
提出日時 2021-11-14 20:56:04
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 825 bytes
コンパイル時間 1,476 ms
コンパイル使用メモリ 165,740 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-30 05:22:03
合計ジャッジ時間 2,391 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int X,Y,L;cin>>X>>Y>>L;
    int com=0;
    if(Y>0)
    {
        if(Y%L)
        {
            com+=Y/L+1;
        }
        else
        {
            com+=Y/L;
        }
        
    }
    else if(Y<0)
    {
        
        com++;
        if(Y%L)
        {
            com+=-Y/L+1;
        }
        else
        {
            com+=-Y/L;
        }
        if(X==0)
        {
            com++;
        }
     
    }
    if(X>0)
    {
      	com++;
        if(X%L)
        {
            com+=X/L+1;
        }
        else
        {
            com+=X/L;
        }
    }
    else if(X<0)
    {
      	
      	com++;
        if(X%L)
        {
            com+=-X/L+1;
        }
        else
        {
            com+=-X/L;
        }
    }
    cout<<com<<endl;
}
0