Fall hit Weekly Training 3

Source: Internet
Author: User

The difficulty of the topic added a bit. But it's still for the novice.

A.diff

The question was hard to see.

The fact is to classify the data on the line.

Let (A[i]-i) the number of equal to a class, any two of them meet a[i] = A[i-k]+k

A[i-flag] Indicates the number of a[i]-i = = I-flag.

The answer is N-max{a[i]}

1#include <cstdio>2#include <iostream>3#include <string.h>4 using namespacestd;5 6 #defineFlag 10000007 8 inta[2000010];9 intb[100010];Ten  One intMainvoid) A { -   intN; -   intMax; thescanf"%d", &n); -    while(N >0){ -     //printf ("****%d\n", n); -Memset (A,0,sizeof(a)); +      for(inti =0; I < n; ++i) scanf ("%d", &b[i]); -      for(inti =0; I < n; ++i) a[b[i]-i+flag]++; +Max =0; A      for(inti =0; I <2000000; ++i) at       if(A[i] >max) -Max =A[i]; -printf"%d\n", N-max); -scanf"%d", &n); -   } -   return 0; in}

B.dogs

This is the logical problem of a bad street. The answer is K.

1#include <cstdio>2 3 intMainvoid)4 {5   intm, N;6    while(SCANF ("%d%d", &m, &n) = =2) printf ("%d\n", n);7   return 0;8}

C.the Position

This is a mistake "no more than" means.

Not less than a person in front, it is only possible in [A+1, N]

No more than B-individuals are in the back, limiting only possible in [N-b, N]

Take the intersection, the number of which is min{n-a, b+1}

1#include <cstdio>2 3 #defineMin (a) (a) > (b)? (b): (a)4 5 intMainvoid)6 {7   intA, B, C;8    while(SCANF ("%d%d%d", &a, &b, &c) = =3) printf ("%d\n", Min (a-b,c+1));9   return 0;Ten}

D.restoring Password

is to test the simple processing of strings.

1#include <cstdio>2#include <string>3#include <iostream>4 using namespacestd;5 6 intMainvoid)7 {8   stringSt;9   strings;Ten   stringa[Ten]; One    while(cin>>St) { A      for(inti =0; I <Ten; ++i) cin>>A[i]; -      for(inti =0; I < the; i + =Ten){ -s =St; theS.erase (i+Ten, --i); -       if(I >0) S.erase (0, i); -       //cout<<s<<endl; -        for(intj =0; J <Ten; ++j) +     if(s = =A[j]) { -cout<<J; +        Break; A     } at     } -cout<<Endl; -   } -   return 0; -}

The 1.st.erase (x, y) represents the deletion of y from the beginning of the first X

2.string seems to use cin,cout more comfortable, anyway scanf,printf compiler did not pass

E.rotating

This problem seems to have been done on cogs years ago.

is a math problem, to simulate on the line.

But once it was submitted, I really can't believe it.

1#include <cstdio>2#include <cmath>3 4 #definePI 3.14159265358985 6 DoubleDisintNintk) {7   returnsqrt2-2*cos (k*2*pi/n));8 }9 Ten intMainvoid) One { A   intN; -   intN, S; -   DoubleCir; the   Doubleans; -scanf"%d", &N); -    for(intz =0; Z < N; ++z) { -scanf"%d%d", &n, &s); +CIR =0; -      for(inti =1; I <= N; ++i) Cir + = DIS (n,i) * (2*PI)/N; +Ans = S/n *Cir; A      for(inti =1; I <= s% n; ++i) ans + = dis (n,i) * (2*PI)/N; atprintf"%.2f\n", ans); -   } -   return 0; -}

Fall hit Weekly Training 3

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.