Reprint please indicate the source, thank you http://blog.csdn.net/ACM_cxlove? Viewmode = contents by --- cxlove
Although it is a test Week, the code is more comfortable...
There are three numbers in 100 PT and three ranges. An initial triple is given and the number of conditions that meet the conditions is as follows: 100*100 *. Direct brute force.
Class randomcoloringdiv2 {public: bool check (int I, Int J, int K, int Sr, int SG, int Sb, int D1, int D2) {If (ABS (I-SR)> D2 | ABS (J-SG)> D2 | ABS (k-Sb)> D2) return false; if (ABS (I-SR) <d1 & ABS (J-SG) <d1 & ABS (k-Sb) <d1) return false; return true ;} int getcount (INT maxr, int maxg, int maxb, int startr, int startg, int startb, int D1, int D2) {int ans = 0; For (INT I = 0; I <maxr; I ++) for (Int J = 0; j <maxg; j ++) for (int K = 0; k <maxb; k ++) if (check (I, j, k, startr, startg, startb, D1, D2) ans ++; return ans ;}};
Question about PT egg pain: How many groups of solutions are there to satisfy the equation? calculate the upper and lower bounds for each step. Pay attention to the boundary.
Class importantsequence {public: int getcount (vector <int> B, string operators) {bool flag = true; For (INT I = 0; I <operators. size (); I ++) if (operators [I] = '+') Flag = false; If (FLAG) Return-1; ll mMax = inf, mmin = 1; for (INT I = 0; I <operators. size (); I ++) {char CH = operators [I]; ll T1 = mMax, T2 = mmin; If (CH = '-') {mMax = max (t1-B [I], (LL) 0); mmin = max (LL) 1, t2-B [I]);} else {mMax = min (max (LL) 0, B [I]-t2), (LL) B [I]-1 ); mmin = max (B [I]-T1, (LL) 1), (LL) 1) ;}} if (mMax <mmin) return 0; return mMax-mmin + 1 ;}};
1000pt number theory ??? The score P/Q is expressed as an infinite decimal number in the number of hexadecimal values. When the factor in the hexadecimal k Includes all the Q factors in the true score P/Q, it can be expressed as a finite decimal number.
Class fractionindifferentbases {public: long gcd (long a, long B) {return B = 0? A: gcd (B, A % B);} long getnumberofgoodbases (long P, Long Q, long a, long B) {q = Q/gcd (p, q); P = 1; for (long I = 2; I * I <= Q; I ++) {If (! (Q % I) {P * = I; while (! (Q % I) q/= I;} p * = Q; return B-A + 1-B/P + (A-1)/P ;}};