Bestcoder Round #11 (Div. 2) The first three questions

Source: Internet
Author: User
Tags cmath

Topic Links:huangjing
hdu5054 Alice and BobIdea: That is (x, y) in the two reference system in the presentation of the same. Then only the midpoint of the rectangle may be. Title: Alice and BobTime limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 216 Accepted Submission (s): 166


Problem Descriptionbob and Alice got separated in the Square, they agreed so if they get separated, they ' ll meet back at The coordinate point (x, y). Unfortunately they forgot to define the origin of coordinates and the coordinate axis direction. Now, Bob in the lower left corner of the square, Alice in the upper right corner of the square. Bob regards the lower left corner as the origin of coordinates, rightward for positive direction of Axis X, upward for POS Itive direction of Axis Y. Alice regards the upper right corner as the origin of coordinates, leftward for positive direct Ion of Axis X, downward for positive direction of Axis Y. Assuming, Square was a rectangular, length and width size is N * M. As shown in the figure:

Bob and Alice with their own definition of the coordinate system respectively, went to the coordinate point (x, y). Can they meet with all other?
Note:bob and Alice before reaching their destination, can not see each other because of some factors (such as buildings, TI Me poor).
Inputthere is multiple test cases. Please process till EOF. Each test case has contains four integers:n, M and X, Y. The Square size is N * M, and meet with coordinate point (x, y). (0 < x < N <=, 0 < y < M <= 1000).
Outputif they can meet with all other, please output "YES". Otherwise, please output "NO".
Sample Input
10 10 5 510 10 6 6

Sample Output
YESNO

Sourcebestcoder Round #11 (Div. 2)
Recommendheyang | We have carefully selected several similar problems for you:5057 5052 5051 5050 5049
Code:
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <map > #include <vector> #include <cmath> #include <string> #include <queue> #define EPS 1e-9# Define ll long Long#define INF 0x3f3f3f3fusing namespace Std;int  main () {    int x,y,n,m;    while (scanf ("%d%d%d%d", &n,&m,&x,&y)!=eof)    {        if (2*x==n&&2*y==m)            printf ("YES \ n ");        else            printf ("no\n");    }  }

HDU 5055 Bob and math problemTest Instructions:is to give n numbers, and then ask you to find a number that satisfies for example the following conditions. (1) This number is odd. (2) This number is the largest number. (3) The other point of Cha is that all the numbers need to be used. I was 0 0 1 was cha. I also have the benefit of such a situation, are the topic did not read AH. Ideas:greedy approach, first of all the bit whether there is a base, assuming that the cardinality is not, then there must be no such number, and then assume that there is, then the smallest cardinality to do you, and then all the bit to sort, and then from the low to high-level assignment, then get this tree, and finally infer that, Assuming that the first is 0, then this number is not present, because all the bits are required to be output. Title:Bob and math problemTime limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 643 Accepted Submission (s): 245


Problem descriptionrecently, Bob had been thinking about a math problem.
There is N Digits, each digit is between 0 and 9. You need to use this N Digits to constitute an Integer.
This Integer needs to satisfy the following conditions:
    • 1. Must is an odd Integer.
    • 2. There is no leading zero.
    • 3. Find the biggest one which is satisfied 1, 2.

Example:
There is three digits:0, 1, 3. It can constitute six number of integers. Only "301", "103" are legal, while "*", "310", "013", "031" is illegal. The biggest one of odd Integer is "301".
Inputthere is multiple test cases. Please process till EOF.
Each case is starts with a line containing an integer n (1 <= n <= 100).
The second line contains N Digits _1, a_2, A_3, \cdots, A_n. (0 \leqwhich indicate the digit $aa_i \leq 9) $.
Outputthe output of each test case of a line. If you can constitute an Integer which are satisfied above conditions, please output the biggest one. Otherwise, Output "-1" instead.
Sample Input
30 1 335 4 232 4 6

Sample Output
301425-1

Sourcebestcoder Round #11 (Div. 2)
Recommendheyang | We have carefully selected several similar problems for you:5057 5052 5051 5050 5049 Code:
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <map > #include <vector> #include <cmath> #include <string> #include <queue> #define EPS 1e-9# Define ll long Long#define INF 0x3f3f3f3fusing namespace Std;const int Maxn=100+10;int A[maxn],odd[maxn];char str[maxn];i    NT N;int Main () {int ans,pd;        while (scanf ("%d", &n)!=eof) {memset (str,0,sizeof (str));        int cnt=0,first=0;            for (int i=1;i<=n;i++) {scanf ("%d", &a[i]);        if (a[i]%2) odd[++cnt]=a[i];        } sort (odd+1,odd+1+cnt);        Sort (a+1,a+1+n);        int ly=n-1;        if (cnt==0) puts ("-1");            else {str[ly]=odd[1]+ ' 0 ';            ly--;                    for (int i=1;i<=n;i++) {if (A[i]==odd[1]&&!first) {                    First=1;                Continue    } else            {str[ly]=a[i]+ ' 0 ';                ly--;            }} if (str[0]== ' 0 ') puts ("-1");                    else {for (int i=0;i<=n-1;i++) printf ("%c", Str[i]);                printf ("\ n"); }}} return 0;}


hdu 5056 Boring countTest Instructions:give a string and then find the number of each letter in all its substrings that does not exceed the sum of all the substrings of K: Ideas:enumerates each character, and then takes each character I as the end of the substring, and then gets the maximum length of the substring that satisfies the condition: Even if the letter is the same, just the location is not the same as the difference. 2333333333, then the idea is to maintain a starting point St, whenever the number of the first character is greater than K, then the St will be moved back, at the same time each of the current cnt[i] minus, until moved to the same character with I you, then from St to I this paragraph will meet the conditions of the character ... Think this idea is really wonderful .... topic;Boring count Time limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 451 Accepted Submission (s): 169


Problem descriptionyou is given a string S consisting of lowercase letters, and your task is counting the number of subst The ring, the number of each lowercase, the substring is no more than K.
Inputin The first line there was an integer T, indicates the number of test cases.
For each case, the first line contains a string which only consist of lowercase letters. The second line contains an integer K.

[Technical specification]
1<=t<= 100
1 <= The length of S <= 100000
1 <= K <= 100000
Outputfor, output a line contains the answer.
Sample Input
3abc1abcabc1abcabc2

Sample Output
61521

Sourcebestcoder Round #11 (Div. 2)
Recommendheyang | We have carefully selected several similar problems for you:5057 5052 5051 5050 5049Code:
 #include < iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <map> #include <vector> #include <cmath> #include <string> #include <queue> #define EPS 1e-9#define ll long long#    Define INF 0x3f3f3f3fusing namespace Std;const int Maxn=100000+10;char str[maxn];int cnt[28];int main () {ll ans;    int t,st,k,ly;    scanf ("%d", &t);        while (t--) {memset (cnt,0,sizeof (CNT));        st=ans=0;        scanf ("%s%d", str,&k);           for (int i=0;str[i]!= ' n '; i++) {ly=str[i]-' a ';           cnt[ly]++;                 if (cnt[ly]>k) {while (Str[st]!=str[i]) {cnt[str[st]-' a ']--;              st++;               } cnt[ly]--;           st++;        } ans+=i-st+1;    } printf ("%i64d\n", ans); } return 0;} 



Bestcoder Round #11 (Div. 2) The first three questions

Related Article

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.