洛谷题号:P2735
用的什么皮克定理,从来没听说过,看的题解。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include<iostream> #include<cstdio> #include<string> #include<algorithm> #include<queue> #include<list> #include<cstring> #include<cassert> using namespace std; int n, m, p; int gcd(int x, int y){ if (x == 0)return y; return gcd(y%x, x); } int main(){ ios::sync_with_stdio(false); cin >> n >> m >> p; int e = gcd(n, m) + gcd(abs(p - n), m) + p; printf("%d", p*m/2 + 1 - e / 2); } |