这道题直接枚举就好了,但我当时竟然没想到,我真是太失败了。。。。。Q_Q
/* ID:abc31261 LANG:C++ TASK:spin */ #include<cstdio> #include<cstring> #include<iostream> using namespace std; const int n=5,maxn=360; int s[10],first[10][10],end[10][10],num[10],f[maxn*2]; bool flag=false; void solve(int h,int l) { for (int i=h;i<=l;i++) { f[i]++; if (f[i]>=5)flag=true; } } int main() { int i,j,l,k; freopen("spin.in","r",stdin); freopen("spin.out","w",stdout); for (i=1;i<=n;i++) { scanf("%d%d",&s[i],&num[i]); for (l=1;l<=num[i];l++) { scanf("%d%d",&first[i][l],&end[i][l]); end[i][l]+=first[i][l]; } } for (l=0;l<=360;l++) { memset(f,0,sizeof(f)); for (i=1;i<=n;i++) for (j=1;j<=num[i];j++) { first[i][j]%=maxn; end[i][j]%=maxn; if (first[i][j]>end[i][j])solve(first[i][j],359),solve(0,end[i][j]); else solve(first[i][j],end[i][j]); } if (flag)break; for (i=1;i<=n;i++) for (j=1;j<=num[i];j++)first[i][j]+=s[i],end[i][j]+=s[i]; } if (flag)cout<<l<<endl; else cout<<"none"<<endl; return 0; }
原文:http://www.cnblogs.com/Sun-Sea/p/5143742.html