Zookeeper
Publishing Company:
Validity Period:
Competition area:
- Difficulty level:
- Answer duration:
- Programming Language Requirements:
- 120 minutes
- C ++ Java C #
Question details[Golden October online programming Competition Rules]
A little girl is counting from 1 to n with her left hand fingers. She starts counting from the thumb as 1. Then, the index finger is 2, the middle finger is 3, the ring finger is 4, and the small finger is 5. Next, adjust the direction. The ring finger is counted as 6, the middle finger is 7, the index finger is 8, and the thumb is 9. Which finger will be parked at the end of the question? The numbers 1, 2, 3, 4, and 5 represent the thumb, index finger, middle finger, ring finger, and small finger in sequence.
Input Format:
Enter multiple groups of data. Each group of data occupies one row and contains only one integer N (1 <=n <= 1000000000 ).
Output Format:
Each group of data occupies one row and only contains an integer between 1 and 5, indicating the last stop finger.
Answer descriptionInput example:
1
10
1000000000
Output example:
1
2
2
Code submitted by me#include<iostream>using namespace std;int main(){ int n; while(cin>>n) { if(n<=5) {cout<<n<<endl;} else { int line,rest; n=n-5; line=1; if(n%4==0) {rest=0;line+=n/4;if(line%2==0) cout<<1<<endl;else cout<<5<<endl;} else {rest=n%4;line+=n/4;line++; if(line%2==0) cout<<5-rest<<endl; else cout<<1+rest<<endl;} } } return 0;}
Golden October online programming Competition No. 1: Little Girl count