The tournament of the Colonel Zheng

Source: Internet
Author: User
Tags acos cmath

Summary: horizontal too vegetable;

Problem B:make pairtime limit:1 Sec Memory limit:128 MB submit:53 solved:40
Submitstatusweb Board Description

Pair<t,t> is a very useful template type in the C + + Standard Template Library, which is a two-tuple. We can use it to represent a two-dimensional coordinate point, a person's height and weight, and so on. The Make_pair () function makes it easy to construct a pair.

There is now an integer array of length n A1~an (which can have the same element), and each of the two elements (including itself) Make_pair () will be able to get N2 pair. For example, [1,2,3]make_pair () will get {[1,1],[1,2],[1,3], [2,1],[2,2],[2,3], [3,1],[3,2],[3,3]}.

The problem is that, after constructing the N2 pair, you can find the nth element after sorting in ascending order (sort by first dimension, if the first dimension is equal and then by the second dimension).

Input

Multiple sets of data.

The first line, 2 integers n and K (1<=n<=10000,1<=k<=n^2).

The second line, n integers, is the original array A1~an (1<=ai<=1000000000).

Output

For each set of data, output two integers, sorted by the K pair.

Sample Input2 4 2 1 3 2 3 1 5 Sample Output2 2 1 3 HINT

Puzzle: Water

Code:

#include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include < algorithm> #include <vector> #include <queue> #include <stack> #include <map>using namespace std;const int Inf=0x3f3f3f3f;const Double Pi=acos ( -1.0); typedef long long LL; #define MEM (x, y) memset (x,y,sizeof) # Define PI (x) printf ("%d", x) #define PL (x) printf ("%lld", x) #define SI (x) scanf ("%d", &x) #define SL (x) scanf ("%lld", &X) #define P_ printf ("") #define T_T while (t--) const int Maxn=10010;int m[maxn];int Main () {int n,k;while (~scanf ("%d% D ", &n,&k)) {for (int i=0;i<n;i++) SI (M[i]), sort (m,m+n);p rintf ("%d%d\n ", m[(k-1)/n],m[(k-1)%n]);} return 0;}
Problem c:water problem iitime limit:1 Sec Memory limit:128 MB submit:80 solved:49
Submitstatusweb Board Description

I believe we are most familiar with the a+b problem.

There is a woman in the laboratory (the legendary Pan classmate) often stuck on this topic ...

Once, he put on the mask side to do the problem, met such a topic:

Enter two English words that represent the number, and output their and. (Of course the input is in English, the output is 10 binary number)

He has a mind too Ben, think for a long while didn't think out how to do? Can you help him?

Input

Multiple sets of input data. Two English words for each set of data input (the input data is 0-9)

Output

For each set of data output one and.

Sample Inputone-OUTPUT3: A+b code:
#include <stdio.h> #include <string.h>int judge (Char s[10]) {if (strcmp ("zero", s) ==0) return 0;if (strcmp (s), "One") ==0 return 1;else if (strcmp (S, "a") ==0) return 2;else if (strcmp (S, "three") ==0) return 3;else if (strcmp (S, "four" ) ==0 return 4;else if (strcmp (S, "five") ==0) return 5;else if (strcmp (S, "six") ==0) return 6;else if (strcmp (S, "seven") ==0) Return 7;else if (strcmp (S, "eight") ==0) return 8;else if (strcmp (S, "nine") ==0) return 9;} int main () {int A,b;char s1[10],s2[10];while (scanf ("%s%s", S1,s2)!=eof) {A=judge (S1); B=judge (S2);p rintf ("%d\n", A+b);} return 0;}

  

Problem e:sorttime limit:1 Sec Memory limit:128 MB submit:125 solved:20
Submitstatusweb Board Description

Presumably everyone was familiar with the sort, but the spy seemed to be unfamiliar with the sort, and one day he saw such a sort of topic:

For K-separated integers with spaces, N1, N2 ... nk. Keep all subscripts that cannot be divisible by 3 but can be divided by 2 in ascending order in the original position of these numbers, in addition, the remaining subscript can be divisible by 3 by the number in the original position of these numbers in descending order.

Spy thought for a long while do not know how to sort, you can help him?

Input

Multiple sets of data, one row per group, a positive integer of K less than 1000, N1, N2 ... nk. (1 <= k <= 100000)

Output

For each set of data, the output is sorted after the result.

Sample INPUT1 3 4 2 6 8 sample OUTPUT1 2 6 3 4 8 HINT

The puzzle: violence can be over;

Code:

#include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include < algorithm> #include <vector> #include <queue> #include <stack> #include <map>using namespace std;const int Inf=0x3f3f3f3f;const Double Pi=acos ( -1.0); typedef long long LL; #define MEM (x, y) memset (x,y,sizeof) # Define PI (x) printf ("%d", x) #define PL (x) printf ("%lld", x) #define SI (x) scanf ("%d", &x) #define SL (x) scanf ("%lld", &AMP;X) #define P_ printf ("") #define T_T while (t--) const int MAXN=100010;INT m[maxn],a[maxn],b[maxn];int CMP (int a,int b) {return a>b;} int main () {int K=0,k1=0,k2=0;char c;while (~scanf ("%d", &m[k++]) {C=getchar (); if (c== ") continue;else{for (int i=1 ; i<=k;i++) {if (i%2==0&&i%3!=0) A[k1++]=m[i-1];else if (i%3==0) b[k2++]=m[i-1];} Sort (A,A+K1), sort (b,b+k2,cmp), int flot=0;int a_i=0,b_i=0;for (int i=1;i<=k;i++) {if (flot) p_;flot++;if (i%2==0 &&i%3!=0) Pi (a[a_i++]), else if (i%3==0) pi (b[b_i++]), Else Pi (m[i-1]);} Puts (""); k=0;k1=0;k2=0;}} Return0;} 

  

Problem H:easy problemtime limit:1 Sec Memory limit:128 MB submit:90 solved:43
Submitstatusweb Board Description

Give you a number. The range of N,n is 1~1000000, which is the smallest positive integer m, the number of bits of the number m plus the sum of its own is exactly n. Of course, if there is no solution, output 0.

Input

The input data consists of multiple sets of data, each consisting of a number N (1<=n<=1000000).

Output

For each set of data, the output contains only one row of an integer m. If there is a minimum of m for each n, the minimum value is output. If the minimum m is not present, the output is 0.

Sample Input216 121 2005 Sample Output198 0 1979 HINT

The puzzle: It is also violence, just beginning to timeout several times, finally think about not need to start from 1, because each digit only and certainly less than 9*6; directly from the n-9*6 start;

Code:

#include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include < algorithm> #include <vector> #include <queue> #include <stack> #include <map>using namespace std;const int Inf=0x3f3f3f3f;const Double Pi=acos ( -1.0); typedef long long LL; #define MEM (x, y) memset (x,y,sizeof) # Define PI (x) printf ("%d", x) #define PL (x) printf ("%lld", x) #define SI (x) scanf ("%d", &x) #define SL (x) scanf ("%lld", &X) #define P_ printf ("") #define T_T while (t--) int main () {int n;while (~scanf ("%d", &n)) {int Flot=0;int x,temp; for (int i=n-60;i<=n;i++) {x=i;temp=0;while (x) {temp+=x%10;x/=10;} if (i+temp==n) {printf ("%d\n", i); flot=1;break;}} if (!flot) {puts ("0");}} return 0;}

  

1817:match numbertime limit:1 Sec Memory limit:128 MB submit:89 solved:39
Submitstatusweb Board Description

Students who like to write programs are generally more sensitive to numbers. For a string of numbers of length 2*n, we think that if it meets the following criteria, it is matched:

Divide the number into the left and right halves, and the length is n. For each digit in the left half, the right half has a number that is strictly greater than it, or for each digit in the left half, the right half has a number that is strictly less than it. Note that each of the right halves must correspond to one of the left halves, that is, each digit can only be "used" once.

Given a number, can you tell if it's a match?

Input

Multiple sets of data.

The first line, 1 integer n (n<1000).

The second line, a string of length 2*n number, is composed of ' 0 ' ~ ' 9 '.

Output

For each set of data, if the number is matched, the output is "YES", otherwise the output "no" (quotation marks are not output).

Sample Input2 2421 2 0135 2 3754 sample Outputyes YES NO HINT

The puzzle: Do not know why to initialize, do not initialize the WA;

Code

#include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include < algorithm> #include <vector> #include <queue> #include <stack> #include <map>using namespace std;const int Inf=0x3f3f3f3f;const Double Pi=acos ( -1.0); typedef long long LL; #define MEM (x, y) memset (x,y,sizeof) # Define PI (x) printf ("%d", x) #define PL (x) printf ("%lld", x) #define SI (x) scanf ("%d", &x) #define SL (x) scanf ("%lld", &AMP;X) #define P_ printf ("") #define T_T while (t--) const int Maxn=2020;char s[maxn];int n;/*int cmp (int a,int b) {if (a<= b) return 1;else return 0;} */int a[maxn],b[maxn];bool js (int tf) {//for (int i=0;i<n;i++) printf ("%d", A[i]);p UTS ("");//for (int i=0;i<n;i++) printf ("%d", B[i]);p UTS (""); if (TF) {for (int i=0;i<n;i++) {if (A[i]>=b[i]) return false;} return true;} else{for (int i=0;i<n;i++) {if (A[i]<=b[i]) return false;} return true;}} int main () {while (~SCANF ("%d", &n)) {mem (a,0); mem (b,0); scanf ("%s", s); for (int i=0,j=n;i<n;i++,j++) a[i]=s[i]-' 0 ',b[i]=s[j]-' 0 '; sort (a,a+n); sort (b,b+n); int tf;if (a[0]<b[0]) tf=1;else tf=0;if (JS (TF)) puts ("YES"); else puts ("NO") ;} return 0;}

  

1819: Gagaga! (oil) Time limit:1 Sec Memory limit:128 MB submit:59 solved:37
Submitstatusweb Board Description

Little d in the lab started playing games again, and this time his game looks very high. First he wrote a number n on a piece of paper, and then he wrote two numbers on two undifferentiated balls, A and B, he put two balls in a black bag, and then he randomly took a ball out of the bag and changed the N to N and the number of marks on the ball.

Isn't it simple! is not very interesting! Isn't it amazing!

Not )

Well, that's not the problem, but the problem is that little D has a possible value for n in the process.

Input

The first line of input contains a k, which represents the number of input sample groups.

Each set of samples has only one row, contains four integers "n a b m", the meaning of n,a,b is the meaning of the title description, m for small d randomly from the bag to take the ball number of times. (0 <= N < 1000000,0 <= a < 100000,0 <= B < 100000, 0 <=m < 10)

Output

Output all possible n in ascending order (not allowed to repeat). Note that spaces are allowed only in the middle of two consecutive numbers, and spaces are not allowed at the end.

Sample INPUT3 1 1 1 1 4 2 3 2 5 102 1 Sample OUTPUT1 2 4 6 7 8 9 10 5 105 107 violent water over ... Code:
#include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include < algorithm> #include <vector> #include <queue> #include <stack> #include <map>using namespace std;const int Inf=0x3f3f3f3f;const Double Pi=acos ( -1.0); typedef long long LL; #define MEM (x, y) memset (x,y,sizeof) # Define PI (x) printf ("%d", x) #define PL (x) printf ("%lld", x) #define SI (x) scanf ("%d", &x) #define SL (x) scanf ("%lld", &AMP;X) #define P_ printf ("") #define T_T while (t--) int C[2][5000],ans[5000];int main () {int t,n,a,b,m;si (T); T_T{SCANF ("%d%d%d%d", &n,&a,&b,&m); int cur=0;int K=0,pol=1;c[0][0]=n;ans[0]=n;while (m--) {cur^=1; for (int i=0;i<pol;i++) {c[cur][i<<1]=c[cur^1][i]+a;ans[++k]=c[cur][i<<1];c[cur][i<<1|1]=c[ CUR^1][I]+B;ANS[++K]=C[CUR][I&LT;&LT;1|1];} Pol<<=1;} Sort (ans,ans+k+1); K=unique (ans,ans+k+1)-ans;for (int i=0;i<k;i++) {if (i) printf ("");p rintf ("%d", Ans[i]);} Puts ("");} return 0;}

  

Zheng He tournament

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.