mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 18:52:02 +00:00
parent
4e851a6934
commit
4891eda3cc
27
S2OJ/1238/1238.cpp
Normal file
27
S2OJ/1238/1238.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user