忘记pick定理是什么了 想枚举来着 。。没枚出来
有篇pick定理的证明 貌似挺好 也没太看懂
1 /* 2 ID: shangca2 3 LANG: C++ 4 TASK: fence9 5 */ 6 #include <iostream> 7 #include<cstdio> 8 #include<cstring> 9 #include<algorithm> 10 #include<stdlib.h> 11 using namespace std; 12 int gcd(int x,int y) 13 { 14 return y==0?x:gcd(y,x%y); 15 } 16 int main() 17 { 18 freopen("fence9.in","r",stdin); 19 freopen("fence9.out","w",stdout); 20 int n,m,p,k=0,ans; 21 double s; 22 cin>>n>>m>>p; 23 s = p*m/2.0; 24 k+=p; 25 k+=gcd(n,m); 26 k+=abs(gcd(n-p,m)); 27 ans = (s+1)-k/2; 28 cout<<ans<<endl; 29 return 0; 30 }