# 3.2.3 Spinning Wheels 纺车的轮子

3.2.3 Spinning Wheels 纺车的轮子

``````30 1 0 120
50 1 150 90
60 1 60 90
70 1 180 180
90 1 180 60``````

``````9
``````

``````#include <iostream>
#include <cstring>
using namespace std;

typedef struct
{
int s;
int w;
int b[5];
int l[5];
}wheels;

wheels wheel[5];
bool isvis[360],res[360];

int main()
{
int i,j,k,p;
for(i=0;i<5;i++)
{
cin>>wheel[i].s>>wheel[i].w;
for(j=0;j<wheel[i].w;j++)
cin>>wheel[i].b[j]>>wheel[i].l[j];
}
for(i=0;i<360;i++)
{
memset(res,true,sizeof(res));
for(j=0;j<5;j++)
{
memset(isvis,false,sizeof(isvis));
for(k=0;k<wheel[j].w;k++)
{
for(p=0;p<=wheel[j].l[k];p++)
isvis[(wheel[j].b[k]+p)%360]=true;
wheel[j].b[k]=(wheel[j].b[k]+wheel[j].s)%360;
}
for(k=0;k<360;k++)
if(isvis[k]==false)
res[k]=false;
}
for(j=0;j<360;j++)
if(res[j]==true)
break;
if(j<360)
break;
}
if(i<360)
cout<<i<<endl;
else
cout<<"none"<<endl;
return 0;
}
``````

``````#include <iostream>
#include <cstring>
using namespace std;

typedef struct
{
int s;
int w;
int b[5];
int l[5];
}wheels;

wheels wheel[5];
bool isvis[360],res[360];

int main()
{
int i,j,k,p;
for(i=0;i<5;i++)
{
cin>>wheel[i].s>>wheel[i].w;
for(j=0;j<wheel[i].w;j++)
cin>>wheel[i].b[j]>>wheel[i].l[j];
}
for(i=0;i<360;i++)
{
memset(res,true,sizeof(res));
for(j=0;j<5;j++)
{
memset(isvis,false,sizeof(isvis));
for(k=0;k<wheel[j].w;k++)
{
for(p=0;p<=wheel[j].l[k];p++)
isvis[(wheel[j].b[k]+p)%360]=true;
wheel[j].b[k]=(wheel[j].b[k]+wheel[j].s)%360;
}
for(k=0;k<360;k++)
if(isvis[k]==false)
res[k]=false;
}
for(j=0;j<360;j++)
if(res[j]==true)
break;
if(j<360)
break;
}
if(i<360)
cout<<i<<endl;
else
cout<<"none"<<endl;
return 0;
}
``````