TopCoder 643 DIV2

Source: Internet
Author: User

Too weak, too weak!

A: The basic judgment, then the boundary problem, wrote for a long time, the results found when the second hand of the room.

B: Really kneeling, it is good to think out, thinking too slow, too slow, the results handed up, too much lag, but hack when a lot of people hung up,

This is also DIV1 's a problem. The practice is:

If it's hard to do with a long long number of factorization.

But the topic tells the number of M/2, M is the number of factorization after decomposition.

Then we want to brush the method first to find out the 1-10^6 of the quality factor.

If n has a mass factor greater than 10^6 of up to 2 (n<=10^18), right.

Then we've written 1, and I'm sure we'll write one.

So we brush it with the prime number of the 1-10^6.

The n!=1 left is also a prime number. The number of saved re-sorts.

C: The question to kneel,

Look at the more simple topics, than the previous topics are simple, but can not think out.

Look at someone else's code, only the Orz is left.

1#include <string>2#include <vector>3#include <iostream>4#include <string.h>5#include <algorithm>6#include <cmath>7 8 using namespacestd;9 TentypedefLong Longll; One intdp[ -][ -][ -]; A intb[ -][ -][ -]; -  -vector<int>mp[123]; the #defineINF 0x3f3f3f - intN; - intson[123]; -  + classThekingstree { -      Public: +  A  at     intDfsintUintRedintGreen) -     { -         if(B[u][red][green])returnDp[u][red][green]; -  -b[u][red][green]=1; -         intC1=red+1; in         intc2=green+1; -          for(intI=0; I<mp[u].size (); i++) to         { +C1+=dfs (mp[u][i],red+1, green); -C2+=dfs (mp[u][i],red,green+1); the         } *         returndp[u][red][green]=min (c1,c2); $     }Panax Notoginseng     intGetNumber (Vector <int>parent) { -      for(intI=0; I<parent.size (); i++) theMp[parent[i]].push_back (i+1); +  A     returnDfs0,0,0); the     } + }; -  $  $ //Powered by Fileedit - //Powered by Tztester 1.01 [25-feb-2003] - //Powered by Codeprocessor

I'll write about what I understand:

DFS (0,0,0) is a traversal from node 0 and its child nodes are red=0,green=0;

Also record whether the state is saved. Memory Flower Search

C1=red+1, (using a sort of reverse approach I think)

The current node is red and then you add its value,

C1+=dfs (V,red+1,green);

Is the value of dye v red. C1 to add its value.

C2 is the representative green, in turn.

PS: This equation can not be written in the game.

TopCoder 643 DIV2

Related Article

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.