SRM 624 D2L3: GameOfSegments, game theory, SD-Grundy theorem, Nimber, spraguegrundy
Question: http://community.topcoder.com/stat? C = problem_statement pm = 13204 rd = 15857
This topic needs to use the classic theory in game theory. The following is a summary of relevant theories:
Impartial Game: a fair Game. The two sides are the same except who starts the Game first.
Nim: a classic Impartial Game. Many games can be equivalent to Nim.
Nimber (Grun
at the border, so only multiply $n -1$The other is to put the $i$ ball in the middle of a position, assuming that the left side of the $j$ ball, then the transfer is necessarily$ $DP [i]=\sum\limits_{j=1}^{i-2}c_{i-1}^j*dp[j]*dp[i-j-1]* (n-2) $$So the total shift is$ $DP [i]= (\sum\limits_{j=1}^{i-2}c_{i-1}^j*dp[j]*dp[i-j-1]* (n-2)) +2*dp[i-1]* (n-1) $$The answer is obviously $dp[n]$.Long LongDp[max_n];Long LongMod=1000000007;Long LongC[max_n][max_n];classsumoverpermutations{ Public: int
Enumerates the number of cases in which Alice throws the dice to get results.Enumeration Bob throws the dice to get the result of the extreme number of each case.Then enumeration Alice throws the dice to get the number of results and Bob throws the dice lower than Alice's number.The results are then computed.#include tc-srm-626-div1-250
to dividing all y into y1 parts, C (y-1,y1-1)For each of the multi-plug y, we fortress a Z to prevent y adjacent, then after the end of our z is z2=z-z1-y2, and then insert these z y1 sequence of two ends, the scheme is C (2*Y1,Z2)At this point, the assignment ends#include #include#include#include#includeusing namespaceStd;typedefLong Longll;intn=1000000;intmo=1000000007;intjc[1000011],fc[1000011];intans,tmp,ts,x,y,z,xl,yl,req,zl,dt,tj,m,r,g,b,j,i;intMiintXintz) { intl; L=1; while(z) {if(z%
Objective:As I have been in the DIV2 of the weak dish. I don't know what to say.A: It must be judged that there are 8 ' R ', only one per column per rowQuestion B: Probably int e,int em,int m,int mh,int HThen em can give value to E,M,MH can give value to h,m;I'm doing two points and then judging.C: When encountering number theory, kneel.Seek a*x^2+b*x+c=0 (mod p); p=10^9;Not satisfied with the output-1 a,b,c,x are in "0,999999999";First of all, p=10^9 is very special, so consider it from here.p=
#defineEPS 1e-9#defineAll (x) X.begin (), X.end ()#defineINS (x) Inserter (X,x.begin ())#definefor (i,j,k) for (int i=j;i#defineMAXN 1005#defineMAXM 40005#defineINF 0X3FFFFFFFusing namespaceStd;typedefLong LongLL; LL I,j,k,n,m,x,y,t,big,cas,num;BOOLFlag; LL Cur,ans;BOOLprim[2000005]; LL ver[2000005]; voidGetprim (ll size) {ll m=SQRT (size+0.5); memset (Prim,0,sizeof(prim));//can be emptied according to the situationnum=0;//put the found prime number in the Ver array, num is the length of the ver
2333 ...Because the TC is too few participants. Plus constantly FST I dropped div2 that.Fortunately, the finished back Div1 the.250The problem of water500The problem of water.Direct BFS expansion.Pay attention to the weight. I also started with Cantor. It's really superfluous.1000The question test instructions the wrong understanding.I said, look at the code, it's not right.It's just a very easy question.Binary enumeration of which leaf nodes to burnAnd then for each method of burningFind the sh
= 1000000007;const int N = 55; ll dp[n][n];void Add (ll a, ll b) {A + = B;a = (a% mod + MoD)% MoD;} ll Mut (ll A, ll b) {a = a * b% Mod;a = (A + MOD)% Mod;return A;} LL gao_up (vectorDIV1 250PTExtract all the l,r, first infer whether it is consistent.And then compare the positionDIV1 PTThe XOR result is less than or equal to limit, the case of equality is processed first, and the result is different or results each bit is equal to the limit, and the column equation Group is evaluated for rank.o
must lose, we can use the memory of the search to achieve the above process ~ ~ ~Code:1vectorint>Card;2 intdp[ -][555], N;3 intDfsintThintmask)4 {5 if(Mask = =511)return 1;6 if(th = = N)return 0;7 if(~dp[th][mask])returnDp[th][mask];8 intCNT =0;9 for(inti =0; I if((Card[i] | mask) = = mask) cnt++;Ten if(cnt > th !dfs (th +1, mask))returnDp[th][mask] =1; One for(inti =0; I if((Card[i] | mask)! =mask) A { - if(!dfs (th +1, Mask | Card[i]))returnDp
Test instructions: Give a n*m chess board, choose a position (x, y), place a horse, the horse can go to (x-1,y-1), (x-1,y-2), (x-1,y+1), (x-1,y+2), (x+1,y-1), (x+1,y-2), (x+1,y+1), (x +1,Y+2) Eight positions, provided that the board cannot be walked out. A horse can walk forever. Q. What is the maximum number of different positions the horse can walk to?Solution: If N>m,swap (n,m), if N=1,ans=1, if n=2,ans= (m+1) >>1; if n=3 and m=3,ans=8; other conditions ans=n*m;Specifically why, not yet prove
From A.M. To the lab, I flipped through my mailbox to see the TC email... SRM 546, because I went to review last night and didn't come to the lab, I don't know how to play again. T_t took an hour out in the morning and flipped through...
250pt
Question
550pt
Difficult to think about. My thinking is complicated and hard to write. Then we can see other people's writing, just a few lines without wordsCodeDone. I have to admire it.
Class Tworec
Test instructions: Give two large integers to determine which one is larger. Large integers are given in "AB" form, "a" is an integer without a leading 0 (greater than 0, not more than 1e9), and "B" is a number (possibly empty) factorial symbol ("!"). For example: 3!! =6!=720Solution: Set two large integer form a part of the A,b;b section respectively has n1,n2 a symbol. Assuming N1 > n2, then we just need to determine the size of AA and B, where A is (N1-N2) a factorial symbol. N1 = N2 or N1 My
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.