南京理工1747(数论)WA了好多遍!
http://219.230.70.12/Local/1747
#include<cstdlib>
#include<iostream> #include<cstdio> #include<cmath> #include<string> #include<cstring> #include<algorithm> #include<set> #include<map> #include<list> #include<queue> #include<vector> #define ULL unsigned long long #define LL long long #define UI unsigned int #define inf 0x7fffffff #define eps 1e-7 #define N 1009 #define M 20009 using namespace std; int T,n,m,k,t; int x[N],y[N],z[N]; int gcd(int a,int b) { if(a<b) swap(a,b); int t; while(b) { t=a%b; a=b; b=t; } return a; } int main() { #ifndef ONLINE_JUDGE freopen("ex.in","r",stdin); #endif // int ncase=0; // scanf("%d",&T); while (scanf("%d",&n)!=EOF) // while (T--) { for (int i=0; i<n; ++i ) scanf("%d%d%d",&x[i],&y[i],&z[i]); int ok=1; for (int i=0; i<n&&ok; ++i ) { for(int j=i+1; j<n; ++j) { int g=gcd(x[i],x[j]); int maxv=max(z[j]-y[i],z[i]-y[j]); int minv=max(0,y[j]-z[i]); minv=max(minv,y[i]-z[j]); if(maxv%g==0) { ok=0;break; } int t=maxv/g; if(minv<=t*g) { ok=0;break; } } } if(ok) printf("Can Take off\n"); else printf("Cannot Take off\n"); } return 0; }