More than 2014 schools join-Sixth session

Source: Internet
Author: User

These two games are helpless recently...

The last 30 minutes of today's round-robin, the pressure doubled. Although the idea is clear, the Code is not easy to work.

However, debugging is finished in about 25 minutes. Submit Wa and submit again. The last five minutes are still not ac-enabled.

First thought it was a problem of precision, and then Sb found that the original array was opened small.

It is not easy to ensure code efficiency and quality in a stress environment. But the array is too small to be opened.

1001: Map

The question is equivalent to several linked lists. Arrange the linked list into several rows.

Then, the number of operations performed on the status of each column is enumerated.

Then sum up the sum and divide it by the total number of States.

# Include <iostream> # include <stdio. h> # include <vector> # include <queue> # include <stack> # include <string. h >#include <algorithm> # include <map> using namespace STD; # define ll long # define lcm (a, B) (a * B/gcd (, b) int su [1010] [1100]; int A [10100]; int have [1010]; int pre [10100]; int next [11000]; vector <int> VEC; int maxlen; int Pan (int p, int t) {int n = Vec. size (); For (INT I = 0; I <n; I ++) {If (T & (1 <I )) {If (SU [I] [p] = 0) Return 0 ;}} return 1 ;}double use (int p, int t) {int n = Vec. size (); int S, X, Y; X = have [p]; y = 0; S = 0; For (INT I = 0; I <N; I ++) {If (T & (1 <I) {y ++; S + = A [Su [I] [p] ;}} if (Y> 1) {return 1.0 * y * s/x + S;} else return s;} void DoS () {int n = Vec. size (); int T = 1 <n; t --; double ans = 0; double pp = 1.0; For (INT I = 0; I <n; I ++) {pp * = 1.0 * (SU [I] [0] + 1);} PP --; For (INT I = 1; I <= maxlen; I ++) {for (Int J = 1; j <= T; j ++) {If (PAN (I, J) = 0) continue; double sum = use (I, j); double CH = 1.0; For (int K = 0; k <n; k ++) {If (J & (1 <k) {Ch * = 1.0 * (SU [k] [0]-I + 1 );} else {Ch * = 1.0 * min (SU [k] [0] + 1), I) ;}} ans + = sum * Ch ;}} printf ("%. 3f \ n ", ANS/PP);} int main () {int t, n, m; scanf (" % d ", & T); While (t --) {memset (have, 0, sizeof (have); memset (PRE, 0, sizeof (pre); memset (next,-1, sizeof (next )); scanf ("% d", & N, & M); For (INT I = 1; I <= N; I ++) {scanf ("% d ", & A [I]);} Int U, V; while (M --) {scanf ("% d", & U, & V); U ++; V ++; pre [v] = u; next [u] = V;} Vec. clear (); For (INT I = 1; I <= N; I ++) {If (pre [I] = 0) Vec. push_back (I);} memset (Su, 0, sizeof (SU); maxlen = 0; For (INT I = 0; I <Vec. size (); I ++) {int K = 1; for (Int J = VEC [I]; J! =-1; j = next [J]) {su [I] [k] = J; have [k] ++; k ++ ;} su [I] [0] = K-1; maxlen = max (maxlen, k-1);} DoS ();} return 0 ;}

1003: Room and moor

Scanning from the past to the next, if not satisfied, merge the following to the previous step. If not satisfied, continue to merge.

Finally, calculate the result.

# Include <iostream> # include <stdio. h> # include <vector> # include <queue> # include <stack> # include <string. h> # include <algorithm> # include <math. h> using namespace STD; # define EPS 1e-9 # define zero (x) (FABS (x) <EPS? 0: X) # define maxn 110000 struct list {int X; int y; double F; int pre;} p [maxn]; int A [maxn]; double SU (int x, int y) {return (1.0 * X)/(1.0 * x + 1.0 * Y);} void DoS (int n) {P [0]. F = 0.0; P [0]. pre =-1; p [0]. X = 0; P [0]. y = 0; For (INT I = 1; I <= N; I ++) {P [I]. F = SU (P [I]. x, p [I]. y); // cout <I <"" <p [I]. x <"" <p [I]. Y <"" <p [I]. F <Endl; If (zero (P [I]. f-P [I-1]. f)> = 0) {P [I]. pre = I-1; continue;} For (Int J = I-1; J! =-1; j = P [J]. PRE) {P [I]. X + = P [J]. x; P [I]. Y + = P [J]. y; P [I]. pre = P [J]. pre; P [I]. F = SU (P [I]. x, p [I]. y); If (zero (P [I]. f-P [p [I]. pre]. f)> = 0) break;} double sum = 0.0; For (INT I = N; I! =-1; I = P [I]. PRE) {double PS = 0; double F = P [I]. f; PS + = f * 1.0 * P [I]. y; F = 1.0-f; PS + = f * 1.0 * P [I]. x; sum + = Ps;} printf ("%. 6f \ n ", sum) ;}int main () {int t, n; scanf (" % d ", & T); While (t --) {scanf ("% d", & N); For (INT I = 1; I <= N; I ++) {scanf ("% d ", & A [I]) ;}int ls = 0; int leap = 1; for (INT I = 1; I <= N; I ++) {If (LS = 0) {if (a [I] = 0) continue; else {ls ++; P [ls]. X = 1; p [ls]. y = 0; Continue ;}}if (LEAP = A [I]) {If (LEAP = 0) P [ls]. Y ++; else P [ls]. X ++;} else {leap = leap ^ 1; if (LEAP = 1) {ls ++; P [ls]. X = 0; P [ls]. y = 0;} I --;} // cout <ls <"<p [ls]. x <"" <p [ls]. Y <Endl;} If (P [ls]. y = 0) ls --; // cout <"_" <ls <Endl; If (LS = 0) {printf ("%. 6f \ n ", 1.0 * ls); continue;} DoS (LS);} return 0 ;}

1005: apple tree

Obviously, we can find that Apple and fertilizer are the best choice. There are two methods in total.

Just simulate it.

1007: Series 1

The final coefficient of detachment is a Yang Hui triangle. Then + and-alternate.

But it is a large number of sad. Java is used...

Sorrow

Import Java. util. imports; import Java. math. *; public class main {public static void main (string [] ARGs) {program CIN = new program (system. in); biginteger [] bit = new biginteger [3300]; biginteger ans, temp, Sn; int I, Cas, N, J, K; CAS = cin. nextint (); for (I = 1; I <= CAS; I ++) {ans = biginteger. zero; temp = biginteger. one; n = cin. nextint (); Sn = biginteger. valueof (n-1); For (j = 1; j <= N; j ++) bit [J] = cin. nextbiginteger (); For (j = 0; j <n; j ++) {If (J % 2 = 0) ans = ans. add (temp. multiply (bit [n-J]); else ans = ans. subtract (temp. multiply (bit [n-J]); temp = temp. multiply (SN ). divide (biginteger. valueof (J + 1); Sn = Sn. subtract (biginteger. one);} system. out. println (ANS );}}}
1010: fighting the landlords

This question will be left empty...

Obviously, I saw the wrong question at the beginning...

It is a simulation question of water. Ignore it ....









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.