csu and dsu

Want to know csu and dsu? we have a huge selection of csu and dsu information on alibabacloud.com

CSU 1805 three capitals (Matrix tree theorem +best theorem)

; *a=a*a%MoD; $n>>=1;Panax Notoginseng } - returnans; the } + A ll C (ll n,ll m) the { + return(F[n]*qpow (f[m],mod-2)%mod) *qpow (f[n-m],mod-2)%MoD; - } $ $ ll Calc () - { - return(a[1][1]*a[2][2]%mod-a[1][2]*a[2][1]%MOD+MOD)%MoD; the } - Wuyi intMain () the { - //freopen ("In.txt", "R", stdin); Wu init (); - while(~SCANF ("%d%d%d",a,b,c)) About { $ if((A+C) 1|| (a+b) 1|| (B+C) 1) {puts ("0");Continue;} -ll ans=0; - for(intI=0; i//enumerates the n

CSU-ACM2016 Summer Camp Training 2-dfs (c-network saboteur)

Impressions: Depth First has a deeper understanding, just beginning to write the idea of a little confusion, do not know how to write recursion, export also made a mistake, over and over the process of deep understanding.#include #include#includeusing namespacestd;inta[ +],b[ +],c[ +][ +],n,sum,tp=0, tp2=0;voidBFsintTpintl);intMain () {memset (A,0, +); //memset (b,-1,21); while(SCANF ("%d", n)! =EOF) { for(intI=0; i) for(intj=0; j) scanf ("%d",C[i][j]); BFS (0,1); printf ("%d\n", su

CSU 1720 How to Get 2^n (large number +hash)

Test instructions: Give you 10W numbers, each number is a large number, the range is 1 to 10^30, and then ask you how many ways, each time you choose two number, two number and 2 powerThe following: 10 of 30 times is about 2 100 times, so first pre-processing 2 102 times, then each input a large number, enumeration 2 power to reduce it, and then go to map to find how many solutions, in fact, is a very simple idea, but I have been writing fried, mainly large number of templates is too poor, will

CSU 1725 Garrosh hell growl vs Ghost thief Rafam (DP)

Test instructions: X attacks, Garrosh have y blood, z three blood slave master, and then the slave owner every one of the non-fatal damage will be regenerated a Slave Lord, on the field up to 7 slave owners, ask you the last to kill Garrosh the probability of how much?Problem: DP recursion, the key is how to design the state, the beginning did not think well, was the gold medal ye Hu a sentence with crooked to the shape of pressure, in fact, the state does not need any four-way pressure, in fact

CSU 1566The Maze Makers

;}BOOLImapintXintY) {if(x>=0x0AMP;AMP;Yreturn 1;return 0;}Const intn= -;intdir[4][2] = {0,-1,1,0,0,1, -1,0};intMp[n][n];CharS[n];intVis[n][n];intVis2[n*n]; vectorint>G[n*n];intDfsintUintP) {intX=getx (U);intY=gety (U); vis[x][y]++;intM=g[u].size (); for(intI=0; iintV=g[u][i];intXx=getx (v);intYy=gety (v);if(V!=p!vis[xx][yy]) DFS (V,U); }return 0;}intDFS1 (intUintP) {//printf ("%d\n", u); if(Vis2[u]) {return 1; } vis2[u]=1;intM=g[u].size (); for(intI=0; iintV=g[u][i];if(v!=p)if(DFS1 (V,u))retu

The IQ of the CSU 1597 Xue xx offspring

,mod;ll N;structmatrix{intA[MAXN][MAXN]; Matrix () {memset (A,0,sizeof(a));} Matrixoperator* (ConstMatrix p) {Matrix res; for(intI=0; i) { for(intj=0; j) { for(intk=0; k) {Res.a[i][j]+ = (a[i][k]*p.a[k][j]%MoD); } Res.a[i][j]%=MoD; } } returnRes; }}ans,Base; Matrix Quick_pow (MatrixBase, ll N) {Matrix res; for(intI=0; i) {Res.a[i][i]=1; } while(n) {if(n1) res=res*Base; Base=Base*Base; N>>=1; } returnRes;}voidInit_matrix () {

CSU 1530:gold Rush (greedy)

http://acm.csu.edu.cn/OnlineJudge/showsource.php?id=97234#include   CSU 1530:gold Rush (greedy)

acm--string--csu--1550--Simple string

strings of length 2*n, a, B, and then given a 2*n long string c,c string consisting of n strings in A, B, to determine whether a given two string can form C.Analysis:By test instructions, we can list 9 scenarios: Judging if a string in C is compliant with test instructions.Because one of the letters in A, B is up to N to form C, (when a string of a B is greater than n, it can only be taken out of N) in order to satisfy the conditions that make up the C string. A[i] A[i]

CSU 1806 Toll

LongLL;Const DoublePi=acos (-1.0), eps=1e-8;voidFile () {freopen ("D:\\in.txt","R", stdin); Freopen ("D:\\out.txt","W", stdout);} TemplateclassT>inlinevoidRead (T x) { Charc = GetChar (); x =0; while(!isdigit (c)) C =GetChar (); while(IsDigit (c)) {x = x *Ten+ C-'0'; c =GetChar (); }}intn,m,t;structedge{intU,v,c,d,nx;} e[ $];inth[ -],sz;voidAddintUintVintCintd) {e[sz].u=u; E[sz].v=v; E[sz].c=c; E[sz].d=D; E[sz].nx=h[u]; h[u]=sz++;}DoubleSPFA (Doublex) { Doubledis[ -];BOOLflag[ -]; for(i

CSU 1507 Super Large LED display tenth session of Hunan Province game problem

Title Link: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1507Problem-solving ideas: This is a simulation problem, read so many people's code, I think my code is the simplest, haha, in fact, the score changes in the time to calculate the lamp light number of complex, I was directly violentAC Code:#include #include#include#includeusing namespacestd;Const intm=45000;intc[Ten]={6,2,5,5,4,5,6,3,7,6};Chara[5],b[5];structnode{intx, Y, Z;} T[M];intMain () {intCa=1; while(1) { inti=-1, g=0, h=0,

"Topology" "Wide Search" CSU 1084 Direction-free graph (2016 Hunan province 12th session of college students computer Program design Competition)

); the #endif - inti,j,k; in intx, y, z the //for (scanf ("%d", cass); cass;cass--) the //for (scanf ("%d", cas), cass=1;cass About //while (~scanf ("%s", s+1)) the while(~SCANF ("%d",N)) the { thelll=aans=0; Mem (Last,0); Mem (inch,0); Mem (d,0); +scanf"%d",m); - for(i=1; i"%d%d", aa+i,bb+i); the for(i=1; i)Bayi { thescanf"%d%d",x,y); theAdd (x, y);inch[y]++; - } - Tuopu (); theprintf"%lld\n", Aans); the } the return 0; the } - /* t

Queries on the "CSU 1079" tree

http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1079There is a tree with n vertices, and the vertices are numbered 1, 2, ..., N. For each query that is shaped like a B K, you need to answer whether the point K is included in the path from point A to to B.DFS sequence Euler sequence lca-recent public ancestorAfter reading these two articles will be doneFirst find out the nearest common ancestor P (Because tree path → (a→p→b)) of a, B, we need to find out if there is a point k on this road.Conve

CSU 1660 K-cycle (Dfs determines if there is a ring of length K in the non-graph)

Test instructions: Give you an no-map to determine if there is a ring of length k.Idea: DFS traversal has a ring with a length of k at each point as the starting point. Now in DFS (NOW,LAST,STEP) represents the current point, last represents the previous point of access, step is a record path length counter, and S "I" records the path length from the starting point to the I point. If a point is accessed a second time, then the ring appears, judging the current path length and whether it is the f

Coderforces Gym 100803a/aizu 1345/CSU 1536/uvalive 6832 Bit String reordering (not finished)

equivalent length of the queue memory equivalent to 3 to 4 times times the same intTherefore, we should be careful to use the STL, for the sake of insurance, with the queue when the limit capacity of the data input is not more than 1e7, that is, 1/10int in 32768KB capacity aroundBlack technology using bit arithmetic in the code of Solution 1/2FORD (i,n-1,0) {cin>>x; Start+=xi;}intC=N; For (I,1, M) {cin>>x; For (J,1, X) {C--; End1+=dightC; End2+=(1-dight) C; } dight^=1;}/// if((fr (111))) {an

DP---CSU 1547:rectangle

Rectangleproblem ' s Link: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1547 Mean:give you some 1 or 2 wide planks, and let you put it in a box with a width of two, asking you how long the box is.Analyse:Simple DP, first thought wrong.Time Complexity:o (n)Source Code://Memory Time//1347K 0MS//by:crazyacking//2015-03-29-22.02#include #include#include#include#include#include#includestring>#include#include#include#include#include#defineMAXN 10005#defineLL Long Longusing namespaces

CSU 1553:good subsequence (longest continuous sub-sequence)

Http://acm.csu.edu.cn/OnlineJudge/problem.php?cid=2071pid=6Test instructions: There is a sequence consisting of n numberRequires a sequence that satisfies Max-minIdea: (I heard that the data big situation can be solved with a monotone stack but I was purely violent)First, enumerate the left bounds and assign Max and Min both to a[i]Then enumerate the right bounds each time to determine whether max-min is less than or equal to KFind the maximum value #include   

STL or segment tree---CSU 1555:inversion Sequence

; i>=0; i--) { if(V.size () A[i]) {OK=0; Break; } v.insert (V.begin ()+1+a[i],i+1); //for (int j=0;j//printf ("%d%c", V[j],j==v.size ()-1? ' \ n ': '); } if(OK) { for(intI=1; i) {printf ("%d%c", V[i],i==n?'\ n':' '); } }Else{puts ("No Solution"); } } return 0; } /************************************************************** problem:1555 user:crazyacking language:c+ + result:accepted time:164 Ms memory:1576 KB *********************************

CSU 1527 Bounty Hunter dp bi-tune Traveler

Topic Link: Click to open the linkNaked Double-tune travel business.#include CSU 1527 Bounty Hunter dp bi-tune Traveler

CSU 1531 Jewelry Exhibition binary matching (bare

Topic Link: Click to open the linkTest instructionsA two-dimensional matrix given [0,n] * [0,m]There are k green dots in the matrix.The following K-line gives the green point coordinates (guaranteed that the given coordinates are not integers and 0 Ask:Use a 1-width brush to dye one line at a time or to dye a columnAsk at least a few brushes to useIdeas:A binary match that maps all points to the lower-left coordinate of the square in which the point is located (that is, discarding the decimal pa

The CSU 1555 inversion Sequence gives the order of the inverted numbers splay

Topic Link: Click to open the linkTest instructionsGive the value of the inverse number to find the original sequence (a 1-n arrangement)1, 2, 0, 1, 0 means that the reverse number of 1 is the reverse number of 2,3 is 0Ideas:From the last number, insert the number of a[i] each time it is inserted into the current sequence.Splay Simulation= = This method is relatively straight (WU) view (NAO), other methods do not want to come out.#include The CSU 1555

Total Pages: 15 1 .... 4 5 6 7 8 .... 15 Go to: Go

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.