数论+思维
The 2021 CCPC Weihai Onsite
J. Circular Billiard Table
https://codeforc.es/gym/103428/problem/J
引用结论:
已知a,b
min x
s.t. ax = by
y属于任意实数
那么 x = b / gcd(a,b)
可以画圈感性理解这个东西,不必取用exgcd去解
(不用exgcd去debug)
#include<bits/stdc++.h>
//#include<gl/glut.h>
//#include<ctime>
#define ll long long
#define mes(a,b) memset(a,b,sizeof(a))
#define ctn continue
#define ull unsigned long long
#pragma warning(disable:4996)
#define tgg cout<<"---------------"<<endl;
const ll linf = 9223372036854775807;
const int inf = 0x3f3f3f3f;
using namespace std;
const double pi = acos(-1);
const ll maxn = 1e5 + 4;
const int mod = 31011;
const double eps = 1e-8;
const ull p = 131;
const ull pc = 13331;
inline ll gcd(int a, int b) {
while (b ^= a ^= b ^= a %= b);
return a;
}
int main(int argc, char* argv[]) {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t;
cin >> t;
while (t--) {
ll a, b;
cin >> a >> b;
cout << (180 * b) / (gcd(180 * b, a)) - 1 << endl;
}
return 0;
}