intさわだんのBlack History

刹那的レジェンドになりたい。

SRM401 (div.2) 250point

がち黒歴史コードになった。
あとで直したい。

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

class DreamingAboutCarrots{
public:
	int carrotsBetweenCarrots(int x1, int y1, int x2, int y2){
	
	int ans = 0;

	if(x1 > x2){
	int xx = x1 - x2;
	int yy = y1 - y2;
	}else{
	int xx = x2 - x1;
	int yy = y2 - y1;
	}
	
	for(int i = 1;i < xx;i++){
		if(yy * i % xx == 0) ans++;
	}
	
	int kans = 0;
	
	if(y1 > y2){
	yy = y1 - y2;
	xx = x1 - x2;
	}else{
	yy = y2 - y1;
	xx = x2 - x1;
	}
	
	for(int i = 1;i < yy;i++){
		if(xx * i % yy == 0) kans++;
	}
	
	return max(ans,kans);
	
	
	
}
};