Home > Web Front-end > HTML Tutorial > BestCoder Round #11 (Div. 2) Solutions to the first three questions_html/css_WEB-ITnose

BestCoder Round #11 (Div. 2) Solutions to the first three questions_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:56:54
Original
1181 people have browsed it

Title link:

huangjing

hdu5054 Alice and Bob

Idea:

That is (x, y) in The representation in both reference frames is exactly the same. Then it is only possible at the midpoint of this rectangle. .

Title:

Alice and Bob Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission( s): 216 Accepted Submission(s): 166


Problem Description

Bob and Alice got separated in the Square, they agreed that 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 positive direction of axis Y. Alice regards the upper right corner as the origin of coordinates, leftward for positive direction of axis X, downward for positive direction of axis Y. Assuming that Square is 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 each other?
Note: Bob and Alice before reaching its destination, can not see each other because of some factors (such as buildings, time poor).


Input

There are multiple test cases. Please process till EOF. Each test case only contains four integers : N, M and x, y. The Square size is N * M, and meet in coordinate point (x, y). ( 0 < x < N <= 1000 , 0 < y < M <= 1000 ).


Output

If they can meet with each other, please output "YES". Otherwise, please output "NO".


Sample Input

                  <p class="sycode">                      10 10 5 510 10 6 6                  </p>
Copy after login


Sample Output

                  <p class="sycode">                      YESNO                  </p>
Copy after login


Source

BestCoder Round #11 (Div. 2)


Recommend

heyang | 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");    }  } <br> hdu 5055 Bob and math problem </p> <p class="sycode"> Question meaning : </p> <p class="sycode"> is to give n numbers, and then ask you to find a number that meets the following conditions.  </p> <p class="sycode"> (1) This number is an odd number.  </p> <p class="sycode"> (2) This number is the largest number.  </p> <p class="sycode"> (3) Another point that has been challenged is that all numbers must be used. I was just 0 0 1 beaten. . I also deliberately judged this situation because I didn't understand the question. .  </p> <p class="sycode"> Idea: </p> <p class="sycode"> The greedy approach is to first check whether there is a base in all the bits. If there is no base, then there must be no such number. Secondly, if there is, then the minimum Find out the base of each bit, then sort all the bits, and then assign values ​​from low bits to high bits, then you will get this tree. Finally, judge, if the first bit is 0, then this number does not exist, because it is required to output all bit. .  </p> <p class="sycode"> Question: </p> <p class="sycode"> Bob and math problem <strong>Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)<br> Total Submission (s): 643 Accepted Submission(s): 245<br> </strong> <br> <br> </p>
<p class="sycode"> Problem Description </p>   <p class="sycode">    Recently, Bob has been thinking about a math problem.    <br> There are N Digits, each digit is between 0 and 9. You need to use this N Digits to constitute an Integer.    <br> This Integer needs to satisfy the following conditions:    <br>    </p>
<li>1. must be an odd Integer.<br> </li>    <li>2. there is no leading zero.<br> </li>    <li>3. find the biggest one which is satisfied 1, 2.</li>    <br> Example:     <br> There are three Digits: 0, 1, 3. It can constitute six number of Integers. Only "301", "103" is legal, while "130", "310", "013", "031" is illegal. The biggest one of odd Integer is "301".      <p class="sycode">        </p>   <br>   <p class="sycode">    Input   </p>   <p class="sycode">    There are multiple test cases. Please process till EOF.    <br> Each case starts with a line containing an integer N ( 1 <= N <= 100 ).    <br /> The second line contains N Digits _1, a_2, a_3, \cdots, a_n. ( 0 \leqwhich indicate the digit $a  a_i \leq 9)$.   </p>   <p class="sycode">        </p>   <br />   <p class="sycode">    Output   </p>   <p class="sycode">    The output of each test case of a line. If you can constitute an Integer which is satisfied above conditions, please output the biggest one. Otherwise, output "-1" instead.   </p>   <p class="sycode">        </p>   <br />   <p class="sycode">    Sample Input   </p>   <p class="sycode">    <pre style="代码" class="precsshei">                  <p class="sycode">                      30 1 335 4 232 4 6                  </p>
Copy after login


Sample Output

                  <p class="sycode">                      301425-1                  </p>
Copy after login


Source

BestCoder Round #11 (Div. 2)


Recommend

heyang | We have carefully selected several similar problems for you: 5057 5052 5051 5050 5049

代码:

#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];int 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;}
Copy after login


hdu 5056 Boring count

题意:

给出一个字符串,然后求出它所有的子串中每个字母的数目不超过k个的所有的子串的数目。。

思路:

枚举每一个字符,然后以每个字符i为子串末尾,然后得到的满足条件的子串的最长长度。。就算字母相同,只要位置不相同就算不同的。。2333333333,那么思路就是维护一个起点st,每当第i个字符的数目大于k后 ,那么就将st后移,同时将当前的每个cnt[i]减减,直到移动到与i相同的字符你,那么从st到i这段字符就满足条件了。。。觉得这个思路真是神奇。。。。

题目;

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 Description

You are given a string S consisting of lowercase letters, and your task is counting the number of substring that the number of each lowercase letter in the substring is no more than K.


Input

In the first line there is 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


Output

For each case, output a line contains the answer.


Sample Input

                  <p class="sycode">                      3abc1abcabc1abcabc2                  </p>
Copy after login


Sample Output

                  <p class="sycode">                      61521                  </p>
Copy after login


Source

BestCoder Round #11 (Div. 2)


Recommend

heyang | We have carefully selected several similar problems for you: 5057 5052 5051 5050 5049

代码:

#include#include#include#include#include#include#include#include#include#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]!='\0';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;}   


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template