0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:31:59 +00:00

#1238. 常中20181205T1-Simple

https://sjzezoj.com/submission/48928
This commit is contained in:
Baoshuo Ren 2022-02-10 23:41:46 +08:00
parent 4e851a6934
commit 4891eda3cc
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

27
S2OJ/1238/1238.cpp Normal file
View File

@ -0,0 +1,27 @@
#include <algorithm>
#include <iostream>
using std::cin;
using std::cout;
#define endl '\n'
int t, n, m;
long long q;
inline long long lcm(int a, int b) {
return 1ll * a * b / std::__gcd(a, b);
}
int main() {
std::ios::sync_with_stdio(false);
cin >> t;
while (t--) {
long long ans = 0;
cin >> n >> m >> q;
for (long long y = 0; y <= std::min(lcm(n, m) - 1, q) / m; y++) {
ans += (q - y * m) / n + 1;
}
cout << q - ans + 1 << endl;
}
return 0;
}