Usaco Spinning Wheels

Source: Internet
Author: User

There are five opaque discs with no more than five sector notches on each disc, and the five discs overlap, each with a fixed speed rotation, asking how long the light can pass through the discs.

World simulation problem, but at the beginning has been tangled how to judge the state has been enumerated, that is, the problem of weighing, later learned not to judge the weight, when the number of rotations more than 360 times, will return to the starting state.

/*id:modengd1prog:spinlang:c++*/#include <iostream> #include <stdio.h>using namespace std;struct wheel{I    NT speed;    int hole; int sta[5],end[5];};    Wheel Wheel[5];bool Ispass () {int passcounter;        for (int i=0;i<360;i++) {passcounter=0;                    for (int j=0;j<5;j++) {for (int k=0;k<wheel[j].hole;k++) {if (i==270)                i=270; if (Wheel[j]. STA[K]&LT;=WHEEL[J]. END[K]&AMP;&AMP;I&GT;=WHEEL[J]. STA[K]&AMP;&AMP;WHEEL[J].                    end[k]>=i) {passcounter++;                Break } if (Wheel[j]. STA[K]&GT;WHEEL[J]. end[k]&& (I>=wheel[j]. sta[k]| | WHEEL[J].                    end[k]>=i)) {passcounter++;                Break    }}} if (passcounter==5) return true; } return false;}    int main () {freopen ("spin.in", "R", stdin); Freopen ("Spin.out"," W ", stdout);        input for (int i=0;i<5;i++) {scanf ("%d%d", &wheel[i].speed,&wheel[i].hole); for (int j=0;j<wheel[i].hole;j++) {scanf ("%d%d", &wheel[i]. Sta[j],&wheel[i].            END[J]); Wheel[i]. End[j]= (Wheel[i]. End[j]+wheel[i].        STA[J])%360;            }}//rotate for (int i=0;i<360;i++) {if (Ispass ()) {cout<<i<<endl;        return 0; } for (int j=0;j<5;j++) {for (int k=0;k<wheel[j].hole;k++) {Wheel [j]. Sta[k]= (Wheel[j].                Sta[k]+wheel[j].speed)%360; WHEEL[J]. End[k]= (Wheel[j].            End[k]+wheel[j].speed)%360;    }}} cout<< "None" <<endl; return 0;}

  

Usaco Spinning Wheels

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.