結果

問題 No.48 ロボットの操縦
ユーザー rhincodon66
提出日時 2018-09-08 18:44:20
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 713 bytes
コンパイル時間 1,635 ms
コンパイル使用メモリ 166,048 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-17 16:31:35
合計ジャッジ時間 2,307 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x,y,l;cin >> x >> y >> l;
	int ans=0;
	if(y>=0){
		if(y%l==0) ans+=y/l;
		else ans+=y/l+1;
		if(x>0){
			ans++;
			if(x%l==0) ans+=x/l;
			else ans+=x/l+1;
		}
		else if(x<0){
			ans++;
			if(abs(x)%l==0) ans+=abs(x)/l;
			else ans+=abs(x)/l+1;
		}
	}
	else{
		if(x>0){
			ans++;
			if(x%l==0) ans+=x/l;
			else ans+=x/l+1;
		}
		else if(x<0){
			ans++;
			if(abs(x)%l==0) ans+=abs(x)/l;
			else ans+=abs(x)/l+1;
		}
		else ans++;
		ans++;
		if(abs(y)%l==0) ans+=abs(y)/l;
		else ans+=abs(y)/l+1;
	}
	cout << ans << endl;
}
0