uva timecard

Read about uva timecard, The latest news, videos, and discussion topics about uva timecard from alibabacloud.com

"Displacement, reasoning" UVa 1315-creaz Tea Party

2 3 | 6 7 5...4 3 1 2 | 7 6 54 3 2 1 | 7 6 5So each number needs to be exchanged for (even) 0, ..., (N/2)-1, (N/2) -1,...,2,1,0(odd) 0, ..., (N/2), (N/2) -1,...,2,1,0Sum can be."Code": The code may be slightly cumbersome. I can simplify it.1#include 2#include 3 using namespacestd;4 intMain ()5 {6 intT scanf"%d", T);7 while(t--)8 {9 intN, ans =0; scanf"%d", n);Ten if(n%2) One { A intnum = n/2; -Ans = (1+ (num-1)) * (num-1); -Ans + =num; the

Recursive DP UVA 607 scheduling lectures

Topic PortalTest instructions: Professors give students classes, there are n themes, each subject has TI time, the class has two restrictions: 1. Each topic can only be finished in one lesson, can not be separated in a multi-class session; 2. Must be in the order of the topic, not upset. A lesson l time, if the early class, according to the amount of time, students have dissatisfaction. Ask at least a few lessons to finish the topic, if the output of a variety of scenarios with the least degree

UVA 1629-cake Slicing (memory search)

][MAXN]; in intCOU[MAXN][MAXN]; - intN, M, K; to voidinit () { + for(inti =1; I ) - for(intj =2; J ) theCOU[I][J] + = cou[i][j-1]; * for(inti =2; I ) $ for(intj =1; J )Panax NotoginsengCOU[I][J] + = cou[i-1][j]; - } the intCount_num (intR1,intC1,intR2,intC2) { + intA = COU[R2][C1-1]; A intb = cou[r1-1][C2]; the intc = cou[r1-1][C1-1]; + returnCOU[R2][C2]-A-B +C; - } $ intDP (intR1,intC1,intR2,intC2) { $ int cnt =DP[R1][C1][R2][C2]; - if(cnt = I

Recursive DP UVA 590 always on the run

Topic PortalTest instructions: Test instructions is difficult to understand, is a thief in M days from the city 1 flew to the city N minimum cost, entered is each city flew to other cities of the flight.Analysis: Dp[i][j] represents the thief's first day in the city J's minimum cost. State transfer equation: dp[i][j] = min (Dp[i-1][k] + cost[k][j][t%day]) T represents the cost of an aircraft flying to J on T-day KHarvest:Code:/************************************************* author:running_time

UVA 424-integer Inquiry

; + if(IS[i]; A if(IB.s[i]; theC.s.push_back (%BASE); +g=x/BASE; - } $ returnC; $ } - BOOL operatorConstbiginteger b)Const{ - if(S.size ()!=b.s.size ())returnS.size () b.s.size (); the for(intI=s.size ()-1; i>=0; i--){ - if(S[i]!=b.s[i])returnS[i]>B.s[i];Wuyi } the return false; - } Wu BOOL operator!=(Constbiginteger b)Const{ - returnb This|| * Thisb; About } $ }; -ostreamoperator out

UVA 1252-twenty Questions (state compression dp+ subset enumeration)

Main topic: There are n items, each item has m characteristics, each item may have or not each feature, now assume that an item, by asking certain characteristics to determine the item, ask the maximum number of times you can determine the item.Different strategies for further questioning may be taken after each inquiry, depending on the answer.With D[S][S0], the answer is S0 (that is, the item has S0 in s), at least the number of times it needs to be asked. Enumerates the feature completion rec

Where's the marble? UVa 10474

I wrote the code myself.#include #include using namespace Std;int main (){int N,a[100],b[100],q,flag;int k=1;while (CIN>>N>>Q){for (int i=0;i{cin>>a[i];}for (int j=0;j{cin>>b[j];}Sort (a,a+n);for (int j=0;j{flag=0;coutfor (int i=0;i{if (A[i]==b[j]){coutflag=1;Break}}if (flag==0){cout}}}return 0;}The code written on the book#include #include using namespace Std;int main (){int n,a[100],q,x;int k=1;while (CINGT;GT;NGT;GT;Q){for (int i=0;i{cin>>a[i];}Sort (a,a+n);coutwhile (q--){cin>>x;int P=lower_

UVA-12166 equilibrium Mobile (Modify balance) (Dfs string representation of the two-fork tree)

intDr[] = {0,0, -1,1, -1, -1,1,1};Const intDc[] = {-1,1,0,0, -1,1, -1,1};Const intMOD = 1e9 +7;Const DoublePI = ACOs (-1.0);Const DoubleEPS = 1e-8;Const intMAXN =1000000+Ten;Const intMaxt =10000+Ten;using namespacestd;CharS[maxn];mapint>MP;intCnt//Total leaf nodesvoidDfsintStintEtintDeep ) { if(S[st] = ='['){ intTMP =0; for(inti = st +1; I i) { if(S[i] = ='[') ++tmp; if(S[i] = =']') --tmp; if(!tmp s[i] = =',') {DFS (St+1I1, Deep +1); DFS (i+1, et-1, Deep +1); } }

UVa 11584 Partitioning by palindromes (simple DP)

Test instructions: Given a string, it can be divided into several palindrome strings at least.Analysis: Dp[i] means that the first I characters can be divided into several palindrome, dp[i] = min{1 + dp[j-1] | J-i is a palindrome}.The code is as follows:#pragma COMMENT (linker, "/stack:1024000000,1024000000") #include UVa 11584 Partitioning by palindromes (simple DP)

UVA 562 Dividing coins (01 backpack)

Split the coin.01 Backpack for SUM/2, SUM-2*DP[SUM/2]#include #include#includeusing namespacestd;intvalue[100000],dp[100000];intMain () {intN,m,sum,sum1; CIN>>N; while(n--) {cin>>m; Sum=0; for(intI=1; i) {cin>>Value[i]; Sum+=Value[i]; } sum1=sum/2; Memset (DP,0,sizeof(DP)); for(intI=1; i) for(intj=sum1;j>=value[i];j--) Dp[j]=max (dp[j],dp[j-value[i]]+Value[i]); cout2*dp[sum1]Endl; } return 0;}UVA 562 Dividing coins (01 backpack)

UVA 624 CD (01 backpack)

Path Recording method: If DP[J-VALUE[I]]+VALUE[I]>DP[J] Description took this thing, the mark is 1,For loop flag, found to be 1, printed out, and the capacity of the backpack to reduce, and then in the secondary capacity to look for signs;#include #include#includeusing namespacestd;intvalue[ -],dp[10001],s[ -][10001];intMain () {intn,m; while(cin>>m) {cin>>N; for(intI=1; i) Cin>>Value[i]; Memset (DP,0,sizeof(DP)); memset (s),0,sizeof(s)); for(intI=1; i) for(intj=m;j>=value[i];j--)

UVA 11827 Maximum GCD (input stream)

Title: PortalTest instructions: To find the number of n greatest common divisor, violence will not time out, the difficulty in no number control input.Solution: Enter it in a special way.#include #include#include#includeusing namespacestd;intgcdintAintb) { if(b==0)returnA; returnGCD (b,a%b);}intMain () {intT; CIN>>T; GetChar (); while(t--) { CharC; intdata[ the],cnt=0; while((C=getchar ())! ='\ n') { if(c>='0'c'9') {ungetc (C,stdin);//returns the character C t

UVa 10213 How many Pieces of land? (Calculate geometry + large number)

Test instructions: A circle of land, select n points in the circumference, and then 22 lines, ask how many pieces of this piece of land into?Analysis: This problem uses Euler formula, in the plan, v-e+f=2, where V is the number of vertices, E is the number of edges, F is the number of polygons. For this problem, just calculate V and e as well.We enumerate the diagonal from a vertex, the line to the left of the I point, then the right side of the n-i-2 point, then the two sides of the lines on th

UVA 221-urban elevations (discretized)!!!!!!

);//the lower left corner of the building must be seen for(intI=1; i){ BOOLvis=false; for(intj=0; j1; j + +){ if(B[i].x+b[i].w Break;//Add this sentence, simplify the program, when the right side of the b[i] building is less than x[j] when the point is definitely not visible if(Visible (I, (x[j]+x[j+1])/2)){//true B[i] visible at the midpoint between the left and right bordersvis=true; Break; } } if(Vis) printf ("%d", b

UVa 817 According to Bartjens (violence, DFS)

Test instructions: Give a string consisting of a number, and then add three operation symbols * + in the string, which requires the output of all added operators and the result equals 2000 after the operation. All numbers cannot have a leading 0,And the formula must be legal.Analysis: The problem is very obvious violence, because the longest only 9 digits, that is, a maximum of 8 positions may be inserted in the symbol, of course, there is not so much, so the direct violence on the line, do not

UVA 10375 Choose and divide "unique decomposition theorem"

Test instructions: C (p,q)/C (r,s), 4 numbers are less than 10000, the answer is not greater than 10^8Idea: According to the scope of the answer guess, do not need to use high precision. According to the unique decomposition theorem, each number can be decomposed into a number of primes multiplied. First, all the primes within 10000 are calculated, and the exponent of each molecule part is calculated by using a array to represent the index of the prime number in the unique decomposition formula,

Uva-10881-piotr ' s Ants

and directions of The n ants in the same format and order as in the input. If the or moreants is at the same location, print "Turning" instead of "L" or "R" fortheir direction. If the ant falls off the pole before T seconds,print "Fell off" for that Ant. Print an empty line after each test case. Sample Input Sample Output 1 R5 R3 L10 R10 2 R5 L8 R Case #1:2 Turning6 R2 Turningfell offcase #2:3 L6 R10 R This question is really not simple

UVa 221 City Front view (discretization)

= the;8 9 structbuilding{Ten intID; One Doublex, Y, W, D, H; A BOOL operatorConstbuilding RHS)Const{ - returnX //Overloading - } the }B[MAXN]; - - intN; - Doublex[2*MAXN]; + - BOOLSolveintIDoublemi) + { A if(! (B[i].xreturn false;//returns False when the midpoint is not in the building B[i] range at for(intK =0; K ) - { - if(b[k].yreturn false; - //returns False if there is a building in front of the building and the height is greater than

$UVA $11825 "$Hackers $ ' $Crackdown $"

]}\)\ (\text{equals complete)}\)\ (\text{+1}\ ) \ (\text{(Focus!!) }\)\ (\text{here is an important tip: Enumerate}\)\ (\mathcal{s}\)\ (\text{subset}\)\ (\mathcal{s0}\) . See the following code:f[0]=0;int All=(1How to analyze the time complexity of the above algorithm? \ (qwq\)? It is equal to the sum of subsets of all subsets of the complete \ (\mathcal{(,..., N)}\) , which can also make\ (\mathcal{c (S)}\) represents the number of subsets of set S (it equals \ (\text{2}\)\ (\mathca

UVa 11401 Triangle counting (count DP)

Test instructions: Given a number n, the number of triangles can be formed by arbitrarily selecting 3 numbers from the 1-n.Analysis: Dp[i] indicates that the number of triangles can be formed by arbitrarily picking out 3 numbers from a 1-i.The code is as follows:#pragma COMMENT (linker, "/stack:1024000000,1024000000") #include UVa 11401 Triangle counting (count DP)

Total Pages: 15 1 .... 11 12 13 14 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.