Bestcoder Round #50 (Div.2)

Source: Internet
Author: User
Tags bitset locale cmath

HDU 5364

"Test Instructions":

Problem description
Enter a description
Input has more than one set of data, each set of the first behavior of an n (1 < = n < = 1000), indicating how much the allowance is taken, the second row n digits a1,a2...an, the number of N to receive the allowance (0 < = A[i] < 10000).
Output description
Outputs a number that represents the work number of the person being punished. If no one needs to be punished, then output-1.
Input sample
31 1 242 1 4 3
Output sample
1-1
Hint
In the first example, 1th workers took more money than everyone else combined, so the output was 1. In the second example, there is no more money than the sum of everyone else, so output-1.
"Thinking": If you count each person's lead more than the number of times left, then output this person

Code:

#pragma COMMENT (linker, "/stack:1024000000,1024000000" #include <cctype> #include <cerrno> #include < cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio># Include <cstdlib> #include <cstring> #include <ctime> #include <algorithm> #include <bitset > #include <complex> #include <deque> #include <exception> #include <fstream> #include < functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale># Include <map> #include <memory> #include <new> #include <numeric> #include <ostream># Include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility># Include <valarray> #include <vector>using namespace std; #define REP (i,j,k) for (int i= (int) j;i< (int) k;++ i) #define PER (i,j,k) for (int i= (int) j;i> (int) k;--i) #define LOWBIT (a) A&-a#define Max (A, b) a>b?a:b#define Min (A, B) a>b?b:a#define mem (A, B) memset (A,b,sizeof (a)) typedef long Long ll;typedef unsigned long long llu;typedef double D b;const int N=1e5+10;const int Inf=0x3f3f3f3f;int dir4[4][2]= {{1,0},{0,1},{-1,0},{0,-1}};int dir8[8][2]= {{1,0},{1,1} {0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};int movv[5][2]= {{1,0},{0,1},{0,0},{-1,0},{0,-1}};inline LL read () {int    c=0,f=1;    Char Ch=getchar (); while (ch< ' 0 ' | |        Ch> ' 9 ') {if (ch== '-') f=-1;    Ch=getchar ();        } while (ch>= ' 0 ' &&ch<= ' 9 ') {c=c*10+ch-' 0 ';    Ch=getchar (); } return c*f;}        int N,a[n],x,ok;int Main () {while (scanf ("%d", &n)!=eof) {memset (A,0,sizeof (a));        Ok=-1;            for (int i=1;i<=n;i++) {scanf ("%d", &x);            a[x]++;            If the number of a[x] bigger than sum-a[x];            if (A[x]>n-a[x]) {ok=x;    }} printf ("%d\n", OK); } return 0;}

HDU 5365

"Test Instructions":

Problem Description
Floret is a love of fitness girl, this day she downloaded a running software, the software can record the trail of Floret running. Floret decided to go to the park to run. There were many seats in the park, and Floret wanted to take a break in some of the seats, and she only ran straight lines between the two seats. Floret is a perfectionist, she hopes her final trajectory is a three-sided or a positive quadrilateral or a positive pentagon or a positive hexagon. The little Flower begins to open the running software from a seat and closes after returning to the seat. May I ask how many kinds of flowers are running. Note: It is considered a kind of running method if the two types of seats are set in the same way. And there's no need to stop when you pass a seat.
Enter a description
Enter multiple sets of data per set of data first behavior one n (1 < = n < = 20) indicates the number of seats next n rows, two integers per line xi,yi (0 < = Xi,yi < = 8) represents the coordinates of the seat
Output Description
Number of output scenarios
Input Sample
40 00 11) 01 1
Output Sample
1
"ideas":

Positive solution: The Earth people know that the whole point is not a positive pentagon and positive triangular shape and positive hexagon, so just a violent enumeration of four points to determine whether it is a positive quadrilateral. If you are not a man of the earth, then even if the violent enumeration is triangular and slightly less violent to find positive pentagon and hexagonal is also possible (anyway not found).

Feel this problem Test intelligence ~ ~

Code:

#pragma COMMENT (linker, "/stack:1024000000,1024000000" #include <cctype> #include <cerrno> #include < cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio># Include <cstdlib> #include <cstring> #include <ctime> #include <algorithm> #include <bitset > #include <complex> #include <deque> #include <exception> #include <fstream> #include < functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale># Include <map> #include <memory> #include <new> #include <numeric> #include <ostream># Include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility># Include <valarray> #include <vector>using namespace std; #define REP (i,j,k) for (int i= (int) j;i< (int) k;++ i) #define PER (i,j,k) for (int i= (int) j;i> (int) k;--i) #define LOWBIT (a) A&-a#define Max (A, b) a>b?a:b#define Min (A, B) a>b?b:a#define mem (A, B) memset (A,b,sizeof (a)) typedef long Long ll;typedef unsigned long long llu;typedef double D b;const int N=1e5+10;const int Inf=0x3f3f3f3f;int dir4[4][2]= {{1,0},{0,1},{-1,0},{0,-1}};int dir8[8][2]= {{1,0},{1,1} {0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};int movv[5][2]= {{1,0},{0,1},{0,0},{-1,0},{0,-1}};inline LL read () {int    c=0,f=1;    Char Ch=getchar (); while (ch< ' 0 ' | |        Ch> ' 9 ') {if (ch== '-') f=-1;    Ch=getchar ();        } while (ch>= ' 0 ' &&ch<= ' 9 ') {c=c*10+ch-' 0 ';    Ch=getchar (); } return c*f;} int num[n];int c[n];int t,n,h,ok,a[n];struct node{int x, y;} zy[100];int mat[20][20];int x[n],y[n];int sqr (int x) {return x*x;} int dis (int a,int b) {return SQR (X[a]-x[b]) +SQR (Y[a]-y[b]);}    BOOL Ok3 (int a,int b,int c) {if (Dis (a, b) ==dis (a,c) ==dis (b,c)) return 1; return 0;}    BOOL Ok4 (int a,int b,int c,int d) {int p[6];    P[0]=dis (A, b);p [1]=dis [A,c];p [2]=dis (a,d);p [3]=dis (B,c);p [4]=dis (b,d);p [5]=dis (C,D);    Sort (p,p+6);    if (p[0]!=p[1]) return 0;    if (p[1]!=p[2]) return 0;    if (P[2]!=p[3]) return 0;    if (P[4]!=p[5]) return 0;    if (P[4]!=2*p[3]) return 0; return 1;}        int main () {while (scanf ("%d", &n)!=eof) {for (int i=1;i<=n;i++) scanf ("%d%d", &x[i],&y[i]);        int ans=0; Sum of the SJX/* for (int i=1, i<=n-2; i++) for (int j=i+1; j<=n-1; j + +) for (int k=j+1; k& Lt;=n;     k++) Ans+=ok3 (i,j,k); *///sum of the SBX for (Int. i=1; i<=n-3; i++) for (int j=i+1; j<=n-2; j + +) for (int k =j+1; k<=n-1; k++) for (int p=k+1; p<=n; p++) ans+=OK4 (I,J,K,P);    printf ("%d\n", ans); } return 0;} /*sample INPUT40 1Sample output1*/

HDU 5366:

"Test Instructions":

Problem Description
In order to keep fit, Zjiaq decided to practise martial arts through Mook Jong Piles. Zjiaq wanted to put Mook Jong piles in his own 1*n yard, which was paved with 1*1 tiles. Because Zjiaq is an obsessive-compulsive disorder, so he wants to put a Mook Jong pile on a floor tile, because the Mook Jong pile is longer, so two Mook jong piles between the tiles must be greater than or equal to two, now Zjiaq want to know in the case of at least put a Mook Jong pile, there are how many kinds of pendulum method.
Enter a description
Input has multiple sets of data, the first behavior of each group of data an integer n (1 < = n < = 60)
Output Description
For each set of data output one row indicates the number of placement scenarios
Input Sample
123456
Output Sample
1235812
"ideas":

F[i] for the last Mook Jong pile placed at the I position of the scheme, so that s[i] is the prefix of f[i] and. It is easy to think of F[i]=s[i-3]+1,s[i]=s[i-1]+f[i], and s[n] is the answer. The only point worth noting is that when N is close to 60 it explodes int.

Code:

#pragma COMMENT (linker, "/stack:1024000000,1024000000" #include <cctype> #include <cerrno> #include < cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio># Include <cstdlib> #include <cstring> #include <ctime> #include <algorithm> #include <bitset > #include <complex> #include <deque> #include <exception> #include <fstream> #include < functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale># Include <map> #include <memory> #include <new> #include <numeric> #include <ostream># Include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility># Include <valarray> #include <vector>using namespace std; #define REP (i,j,k) for (int i= (int) j;i< (int) k;++ i) #define PER (i,j,k) for (int i= (int) j;i> (int) k;--i) #define LOWBIT (a) A&-a#define Max (A, b) a>b?a:b#define Min (A, B) a>b?b:a#define mem (A, B) memset (A,b,sizeof (a)) typedef long Long ll;typedef unsigned long long llu;typedef double D b;const int N=1e5+10;const int Inf=0x3f3f3f3f;int dir4[4][2]= {{1,0},{0,1},{-1,0},{0,-1}};int dir8[8][2]= {{1,0},{1,1} {0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};int movv[5][2]= {{1,0},{0,1},{0,0},{-1,0},{0,-1}};inline LL read () {int    c=0,f=1;    Char Ch=getchar (); while (ch< ' 0 ' | |        Ch> ' 9 ') {if (ch== '-') f=-1;    Ch=getchar ();        } while (ch>= ' 0 ' &&ch<= ' 9 ') {c=c*10+ch-' 0 ';    Ch=getchar (); } return c*f;} LL N;    LL Dp[100];int Main () {dp[1]=1;dp[2]=2;dp[3]=3; for (int i=4; i<=60;    ++i) dp[i]=dp[i-1]+dp[i-3]+1;    while (scanf ("%lld", &n)!=eof) {printf ("%lld\n", Dp[n]); } return 0;}


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Bestcoder Round #50 (Div.2)

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.