dovelet - 기울기/slant
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #include <iostream> #include <algorithm> using namespace std; int main() { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; if (x1 != 0 && x2 != 0) { int minMultiple = min(y1 / x1, y2 / x2); for (int i = minMultiple; 1 <= i; i--) { if (x1 * i - y1 == x2 * i - y2) { cout << i << " " << -(x1 * i - y1) << endl; break; } } } else { if(x1 == 0) cout << y2 / x2 << " " << y2 % x2 << endl; else cout << y1 / x1 << " " << y1 % x1 << endl; } return 0; } | cs |
'algorithm ' 카테고리의 다른 글
dovelet - 내/외각의 합/angle (0) | 2016.07.14 |
---|---|
dovelet - maxandmin/maxandmin (0) | 2016.07.14 |
dovelet - 버터 먹기/butter (0) | 2016.07.14 |
dovelet - 사탕/coci_slatkisi (0) | 2016.07.14 |
dovelet - 논문인용/coci_faktor (0) | 2016.07.09 |