Submission #999263


Source Code Expand

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

int a,b,c,d;

int gcd(int x , int y){
	return y > 0 ? gcd(y,x%y) : x;
}

int main(){
	scanf("%d%d%d%d" , &a , &b , &c , &d);
	a = abs(a-c);
	b = abs(b-d);
	if(a == 0 || b == 0){
		printf("0\n");
		return 0;
	}
	int g = gcd(a,b);
	a /= g;
	b /= g;
	printf("%lld\n" , (long long)(a + b - 1) * g);
	return 0;
}

Submission Info

Submission Time
Task E - Segment on Grid Paper
User PIandS
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1073 Byte
Status AC
Exec Time 1 ms
Memory 128 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:31:39: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d%d" , &a , &b , &c , &d);
                                       ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 2
AC × 21
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All sample_01.txt, sample_02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 128 KB
sample_02.txt AC 1 ms 128 KB
subtask1_01.txt AC 1 ms 128 KB
subtask1_02.txt AC 1 ms 128 KB
subtask1_03.txt AC 1 ms 128 KB
subtask1_04.txt AC 1 ms 128 KB
subtask1_05.txt AC 1 ms 128 KB
subtask1_06.txt AC 1 ms 128 KB
subtask1_07.txt AC 1 ms 128 KB
subtask1_08.txt AC 1 ms 128 KB
subtask1_09.txt AC 1 ms 128 KB
subtask1_10.txt AC 1 ms 128 KB
subtask1_11.txt AC 1 ms 128 KB
subtask1_12.txt AC 1 ms 128 KB
subtask1_13.txt AC 1 ms 128 KB
subtask1_14.txt AC 1 ms 128 KB
subtask1_15.txt AC 1 ms 128 KB
subtask1_16.txt AC 1 ms 128 KB
subtask1_17.txt AC 1 ms 128 KB
subtask1_18.txt AC 1 ms 128 KB
subtask1_19.txt AC 1 ms 128 KB