https://www.acmicpc.net/problem/19532
#include <iostream>
using namespace std;
int main()
{
int a, b, c, d, e, f;
int x, y;
cin >> a >> b >> c >> d >> e >> f;
int temp_b = d * b;
int temp_e = a * e;
int temp_c = d * c;
int temp_f = a * f;
if (temp_b - temp_e == 0)
y = 0;
else
y = (temp_c - temp_f) / (temp_b - temp_e);
if (a != 0)
x = (c - b * y) / a;
else
x = (f - e * y) / d;
cout << x << " " << y;
return 0;
}
#include<iostream>
using namespace std;
int a, b, c, d, e, f;
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> a >> b >> c >> d >> e >> f;
for (int i = -999; i <= 999; i++) {
for (int j = -999; j <= 999; j++) {
if ((i * a + j * b == c) && (i * d + j * e == f)) {
cout << i << " " << j;
return 0;
}
else continue;
}
}
}

int x = (c * e - b * f) / (a * e - b * d);
int y = (c * d - a * f) / (b * d - a * e);
수학 공식 (가감범) 으로 풀 수도 있는 연립방정식이지만
시간 제한이 충분하고 정수형의 범위가 넓지 않다면
브루트포스로도 풀 수 있다.