Rogu P2818 Angel's oath, rogu p2818's oath
Description
Tenshi was fortunate to have been chosen as the angel in charge of the keys of wisdom. Before her formal tenure, she had to swear, just like any other new angel. The swearing-in ceremony is the mission of each angel. Their speeches are placed in n polardb boxes. These boxes are numbered 1, 2,… clockwise ,..., N-1, n. At first the angels stood by the treasure box numbered n. Each of them has a number in their hands, representing the number of boxes in which their speeches are made clockwise from box 1. For example, there are 7 boxes. If the number on Tenshi's hand is 9, then the box where her statement is located is 2. Now, the angels start to look for the statement based on their own figures. Tenshi immediately finds out, so she first took the stage and vowed: "I will lead everyone to open the Noi door ......" After the oath of Tenshi, angels gradually took the oath. However, an angel could not find her statement for a long time. The number m in her hand was very large, and she could not find the box she wanted for a long time.
Please help the angel find the treasure box number she is looking.
Input/Output Format
Input Format:
The first behavior is positive integer n, and the second behavior is positive integer m, where n and m meet 2 <= n <= 10 ^ 8, 2 <= m <= 10 ^ 1000
Output Format:
There is only one line (including a line break), that is, the number of the treasure box the angel is looking.
Input and Output sample input sample #1: Copy
79
Output example #1: Copy
2
Input example #2: Copy
11108
Output sample #2: Copy
9
Equality Theorem
123% 11 = (100% 11 + 20% 11 + 3% 11) % 11 = (1% 11*10 + 2) % 11*10 + 3) % 11
The same theorem is widely used.
How can we determine whether a number is a multiple of 3?
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 #define LL unsigned long long 6 using namespace std; 7 const int MAXN=200000001; 8 int n,m; 9 inline int read()10 {11 char c=getchar();int flag=1,x=0;12 while(c<'0'||c>'9') {if(c=='-') flag=-1;c=getchar();}13 while(c>='0'&&c<='9') x=(x*10+c-48)%n,c=getchar(); return x*flag;14 }15 16 int main()17 {18 cin>>n;19 m=read();20 m==0?printf("%d",n):printf("%d",m);21 return 0;22 }