Alibabacloud.com offers a wide variety of articles about remainder theorem exercises, easily find your remainder theorem exercises information here online.
: Given a time of 10, the next occurrence of three peaks on the same day is 12, then output 2 (note that this is not 3). Input inputs four integers: p, E, I, and D. P, E, I, respectively, indicate the time at which the physical, emotional and intellectual peaks appear (the time is calculated from the first day of the year). D is the given time, which may be less than P, E, or I. All given times are non-negative and less than 365, and the time required is less than 21252.When p = e = i = d =-1, t
X problemTime limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)Total submission (s): 4255 Accepted Submission (s): 1359Problem description The number of x in a positive integer less than or equal to n is satisfied: x mod a[0] = b[0], x mod a[1] = b[1], x mod a[2] = b[2], ..., x mod a[i] = b[i], ... (0 The first behavior of input data is a positive integer t, which indicates that there is a T group of test data. The first behavior of each set of test data is two positive
Each of the two a[i] is mutually vegetarian, so there must be a solution, which is a special case in the general mode linear equation Group.1#include 2#include 3 4 using namespacestd;5 Const intN = the;6 7 #definell Long Long8 ll A[n], b[n];9 Tenll EX_GCD (ll A, ll x, LL B, LL y) One { A if(b = =0){ -x =1, y =0; - returnA; the } -ll ans = EX_GCD (b, X, a%b, y); -ll t =x; -X= y, y = t-(A/b) *y; + returnans; - } + //because they are homogeneous, you don't have to calculate the
solution then output-1.Sample InputSample OutputFirst, we can find two congruence equations to set the general solution to N;N=R1 (MOD (M1)), N=R2 (mod (m2));Obviously can be converted into K1*M1+R1=K2*M2+R2;--->k1*m1+ (-k2*m2) =r2-r1;Set a=m1,b=m2,x=k1,y= (-K2), C=r2-r1 equation can be written as ax+by=c;X can be solved by Euclid, then X is the smallest positive integer solution of the original equation (x* (C/D)% (b/d) + (b/d))% (b/d);To see the solution to the linear equation. So this x is t
Big numberProblem Descriptionas We know, Big number is always troublesome. But it's really important in our ACM. And today, your task is to write a program to calculate a mod B.The problem easier, I promise that B'll be smaller than 100000.Is it too hard? No, I work it out in the minutes, and my program contains less than lines.Inputthe input contains several test cases. Each test case consists of positive integers A and B. The length of A would not exceed, and B would be smaller than 100000. Pr
Question address: http://poj.org/problem? Id = 2891
#include
1 Extended Euclidean evaluate the coefficient application in bezout Equations
2. The modulo in the Chinese Remainder Theorem may not necessarily be mutually exclusive.
3. Please restore R1 before updating the A1 value.
Console.WriteLine ("Please enter your ID number");string x = Console.ReadLine ();String year=x.substring (6,4);//starting from the sixth position of the ID card, intercept four, which is your year of birthint x1 = Convert.ToInt32 (year);//The interception into the years into the X1,string sx = "";Switch (X1%12)//Enter a year, if the assumption is four, you can judge the year of the zodiac, and then according to the 12 zodiac arrangement, to determine the balance of 0 to 12 of which Zodiac{Case 0
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.