Solution Report of basic group finals of the third Program Design Competition of Overseas Chinese University

Source: Internet
Author: User
Tags strtok cmath

 

1001 hdu2054 is mainly to consider the large number, but also to deal with leading 0, decimal and followed by 0, there is a negative number. Give a group of data (-01.00-1)

 

1002 hdu2561 is relatively simple most of them have passed this question. The data is relatively watery, and O (N ^ 2) can be sorted. The best method is the O (logn) bidding method, however, we all seem to have written O (n) algorithms.

 

1003 hdu2714 pay attention to the penultimate sentence in the topic description. Except for the last number, X can only be 0-9. Nothing else.

 

1004 hdu1070 in fact, as long as you calculate the average daily spending order, it is OK. Pay attention to the question description and be careful when writing comparison functions.

 

1005 hdu2050 search for the largest character record and print it one by one. If it is Max, add a suffix.

 

1006 read questions in hdu2573 => Simulation => AC

 

1007 there is no special method for hdu3082. It is also a simple simulation.

 

1008 hdu1230 is a purely simulated question, but it involves a prime number, so it is faster to create a table.

 

[Personal thoughts] what I think when I give a question is that it cannot be a very simple question, or it will not be called a "finals. The purpose of the question was to investigate the "programming ability", so there were five questions for the simulation question. The sorting was certainly indispensable, so there were two more questions in sequence. One question was a naked sorting, one question is more practical. Then there was a = B. The purpose of this question is to learn how to observe the ranklist and know what the problem is and which one is simple. So I deliberately put it on the first question. As a result, my students have wasted a lot of time on this question. In the end, my conscience cannot go over. This is why I spent an hour in the competition. As for the individual warm-up match, I am too reluctant to find a question, so it is the same as the basic group question.

 

 

The following is a good code written by the predecessors found on the Internet.

 

[1001]

 

# Include <stdio. h> <br/> # include <string. h> <br/> void fun (char * P) <br/> {int Len = strlen (p); <br/> char * t = P + len-1; <br/> If (strchr (p ,'. ') <br/> while (* t = '0') * t -- = 0; <br/> If (* t = '. ') * T = 0; <br/>}< br/> main () <br/>{< br/> char a [100024], B [100024]; <br/> char * P_a, * P_ B; <br/> while (scanf ("% S % s", & A, & B )! =-1) <br/> {int j_a = 0, j_ B = 0; <br/> P_a = A; P_ B = B; <br/> If (* P_a = '-') {P_a ++; j_a ++ ;}< br/> If (* P_ B = '-') {P_ B ++; j_ B ++ ;}< br/> If (j_a = j_ B) <br/>{< br/> while (* P_a = '0 ') p_a ++; <br/> while (* P_ B = '0') P_ B ++; <br/> fun (P_a); fun (P_ B ); <br/> puts (strcmp (P_a, P_ B )? "No": "Yes"); <br/>}< br/> else <br/> printf ("No/N "); <br/>}< br/>} 

 

[1002]

# Include <iostream> <br/> using namespace STD; <br/> int A [20]; <br/> int main () <br/>{< br/> int t; <br/> scanf ("% d", & T); <br/> while (t --) {<br/> int N; <br/> scanf ("% d", & N); <br/> for (INT I = 0; I <N; + + I) {<br/> scanf ("% d", A + I); <br/>}< br/> sort (A, A + n ); <br/> printf ("% d/N", a [1]); <br/>}< br/> return 0; <br/>} 

[1003]

# Include <iostream> <br/> # include <algorithm> <br/> # include <string> <br/> # include <set> <br/> # include <Map> <br/> # include <utility> <br/> # include <queue> <br/> # include <stack> <br/> # include <list> <br/> # include <vector> <br/> # include <cstdio> <br/> # include <cstdlib> <br/> # include <cstring> <br/> # include <cmath> <br/> using namespace STD; <br/> int main () <br/>{< br/> string STR; <br/> while (CIN>> Str) <br/>{< br/> int n = Str. size (); <br/> int sum = 0, ask = 0; <br/> for (INT I = 1; I <= N; ++ I) <br/> {<br/> switch (STR [I-1]) <br/> {<br/> case 'X ': <br/> sum + = (10-i + 1) * 10; break; <br/> case '? ': <Br/> ask = 10-i + 1; break; <br/> default: <br/> sum + = (10-i + 1) * (STR [I-1]-'0'); break; <br/>}< br/> int Pos =-1; <br/> for (INT I = 0; I <= 10; ++ I) <br/> {<br/> If (sum + ask * I) % 11 = 0) <br/>{< br/> Pos = I; <br/> break; <br/>}< br/> If (ask! = 1 & Pos = 10) Pos =-1; // The Code Wa is very depressing twice. <br/> If (Pos = 10) <br/> cout <'X' <Endl; <br/> else <br/> cout <POS <Endl; <br/>}< br/> return 0; <br/>}< br/> 

[1004]

# Include <iostream> <br/> # include <algorithm> <br/> # include <string> <br/> # include <set> <br/> # include <Map> <br/> # include <utility> <br/> # include <queue> <br/> # include <stack> <br/> # include <list> <br/> # include <vector> <br/> # include <cstdio> <br/> # include <cstdlib> <br/> # include <cstring> <br/> # include <cmath> <br/> using namespace STD; <br/> typedef struct milk {<br/> char name [110]; <br/> int Pa Y; <br/> int vol; <br/> double Wei; <br/>} ml; <br/> ML m; <br/> bool CMP (const ml & A, const ml & B) {<br/> If (. wei! = B. wei) <br/> return. wei <B. wei; <br/> else return. vol> B. vol; <br/>}< br/> int main () <br/>{< br/> int t; <br/> CIN> T; <br/> while (t --) {<br/> int N; <br/> vector <ml> VEC; <br/> CIN> N; <br/> for (INT I = 0; I <n; ++ I) {<br/> CIN> M. name> M. pay> M. vol; <br/> int D = 0; <br/> int T = m. vol; <br/> while (T> = 200 & D <= 4) {<br/> D ++; <br/> T-= 200; <br/>}< br/> If (d) {<br/> M. wei = m. pay * 1.0/d; <br/> Vec. push_back (m); <br/>}< br/> sort (VEC. begin (), VEC. end (), CMP); <br/> cout <VEC [0]. name <Endl; <br/>}< br/> return 0; <br/>}< br/> 

[1005]

# Include <stdio. h> <br/> # include <string. h> <br/> int main () <br/> {<br/> char K [101]; <br/> while (scanf ("% s ", k )! = EOF) // The string does not require "&" <br/>{< br/> int Len = strlen (k ); // read String Length <br/> char max = 'a'; // assign a character value <br/> for (INT I = 0; I <Len; I ++) // loop to find the maximum value in the string <br/> If (K [I]> MAX) max = K [I]; <br/> for (INT I = 0; I <Len; I ++) // output <br/> {<br/> If (K [I] = max) printf ("% C (max)", K [I]); <br/> else printf ("% C", K [I]); <br/>}< br/> return 0; <br/>}</P> <p> 

[1006]

# Include <iostream> <br/> # include <fstream> <br/> # include <sstream> <br/> # include <algorithm> <br/> # include <string> <br/> # include <set> <br/> # include <map> <br/> # include <utility> <br/> # include <queue> <br/> # include <stack> <br/> # include <list> <br/> # include <vector> <br/> # include <cstdio> <br/> # include <cstdlib> <br/> # include <cstring> <br/> # include <cmath> <br/> # include <ctime> <br/> using namesp Ace STD; <br/> bool ISUP = false; <br/> int main () <br/>{< br/> int T; <br/> CIN> T; <br/> while (t --) {<br/> int N; <br/> string STR, word; <br/> CIN> N; <br/> while (n --) {<br/> CIN> STR; <br/> If (Str. size () = 1) {<br/> word + = char (ISUP? Toupper (STR [0]): tolower (STR [0]); <br/>}else if (STR = "Caps") ISUP =! ISUP; <br/> else {<br/> CIN> STR; <br/> word + = char (! ISUP? Toupper (STR [0]): tolower (STR [0]); <br/>}< br/> cout <word <Endl; <br/> ISUP = false; <br/>}< br/> return 0; <br/>} 

[1007]

 

# Include <iostream> <br/> # include <fstream> <br/> # include <sstream> <br/> # include <algorithm> <br/> # include <string> <br/> # include <set> <br/> # include <map> <br/> # include <utility> <br/> # include <queue> <br/> # include <stack> <br/> # include <list> <br/> # include <vector> <br/> # include <cstdio> <br/> # include <cstdlib> <br/> # include <cstring> <br/> # include <cmath> <br/> # include <ctime> <br/> using namespace STD; <br/> char STR [110]; <br/> char * tok; <br/> int main () <br/>{< br/> int T; <br/> scanf ("% d", & T); <br/> while (t --) {<br/> int N; <br/> double res = 0; <br/> scanf ("% d", & N); <br/> for (INT I = 1; I <= N; ++ I) {<br/> scanf ("% s", STR); <br/> Tok = strtok (STR ,"-"); <br/> int T = atoi (Tok); <br/> int r = T; <br/> while (Tok = strtok (null ,"-")) {<br/> T = atoi (Tok); <br/> r + = T; <br/>}< br/> res + = 1.0/R; <br/>}< br/> printf ("%. 2lf/N ", 1.0/RES); <br/>}< br/> return 0; <br/>} 

 

[1008]

# Include <iostream> <br/> # include <string> <br/> # include <algorithm> <br/> # include <cstdlib> <br/> # include <cstdio> <br/> # include <cstring> <br/> using namespace STD; <br/> string a, B; <br/> int prim [40] =, 101,103,107,109,113,}; <br/> int X [30], Y [30]; <br/> int main () {<br/> while (CIN> A> B,! = "0" & B! = "0") {<br/> memset (x, 0, sizeof (x); <br/> memset (Y, 0, sizeof (y )); <br/> Int J = 1, k = 1; <br/> for (INT I = 0; I <. size (); ++ I) {<br/> if (a [I]! = ',') {<Br/> X [J] = x [J] * 10 + A [I]-'0 '; <br/>}else {<br/> + + J; <br/>}< br/> for (INT I = 0; I <B. size (); ++ I) {<br/> If (B [I]! = ',') {<Br/> Y [k] = Y [k] * 10 + B [I]-'0 '; <br/>}else {<br/> + + k; <br/>}< br/> reverse (x + 1, X + J + 1); <br/> reverse (Y + 1, Y + k + 1); <br/> int f = 0; <br/> int M = J; <br/> int Mm = K; <br/> int T = 0; <br/> If (M> mm) {<br/> swap (M, mm); <br/> T = 1; <br/>}< br/> // cout <m <"" <mm <Endl; <br/> int Z [30]; <br/> for (INT I = 1; I <= m; ++ I) {<br/> Z [I] = X [I] + Y [I] + F; <br/> F = Z [I]/prim [I]; <br/> Z [I] % = prim [I]; <br/>}< br/> Z [M + 1] = 0; <br/> for (INT I = m + 1; I <= mm; ++ I) {<br/> int temp = 0; <br/> If (! T) temp = Y [I]; <br/> else temp = x [I]; <br/> Z [I] = temp + F; <br/> F = Z [I]/prim [I]; <br/> Z [I] % = prim [I]; <br/>}< br/> If (f) {<br/> Z [++ mm] = F; <br/>}< br/> for (INT I = mm; I> 0; -- I) {<br/> printf (I = mm? "% D": ", % d", Z [I]); <br/>}< br/> putchar (10 ); <br/>}< br/> return 0; <br/>} 

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.