ACM_Alarm Clock Life (Water Question)

Alarm clock life

Time Limit: 2000/1000ms (Java/Others)

Problem Description:

It is known that a clock initially points to 0 o'clock and goes clockwise for n hours. Find the number it points to at the end (the time is calculated in hexadecimal).

Input:

Multiple sets of input, each with one n(-10^7<=n<=10^7)

Output:

Output the number pointed to by the pointer

Sample Input:

4
12
15

Sample Output:

4
0
3 
problem-solving ideas: water problem! ! ! Take the remainder. However, it should be noted that any number that is not 0 in the remainder of a negative number is a negative number, and the output is required to be in hexadecimal. Negative numbers indicate counterclockwise rotation, so adjust it to a positive number, and then take the remainder from a single outlet and output . water over.
 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int main()
 4 {
 5     int n;
 6     while(cin>>n){
 7         while(n<0)n+=12;
 8         cout<<(n%12)<<endl;
 9     }
10     return 0;
11 }

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325463034&siteId=291194637