首頁 web前端 html教學 BestCoder Round #11 (Div. 2)题解集合_html/css_WEB-ITnose

BestCoder Round #11 (Div. 2)题解集合_html/css_WEB-ITnose

Jun 24, 2016 am 11:57 AM
round 集合

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


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 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

 


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>
登入後複製

 


Sample Output

              <p class="sycode">                  YESNO              </p>
登入後複製

 


Source

BestCoder Round #11 (Div. 2)

 


Recommend

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

  题意:

给一个矩形区域告诉你它的长和宽。然后两个坐标系。一个为左下角为原点。右上为正方向。一个右上角为原点。右下为正方向。现在给你一个坐标(x,y)问你在两种坐标系中他们是不是表示同一个点。

思路:

把不同的坐标系转换到同一坐标系就行了。我是把左上角转换到右下角的。

详细见代码:

#include<algorithm>#include<iostream>#include<string.h>#include<stdio.h>using namespace std;const int INF=0x3f3f3f3f;const int maxn=100010;typedef long long ll;int main(){    int n,m,x,y;    while(~scanf("%d%d%d%d",&n,&m,&x,&y))    {        if(x==n-x&&y==m-y)            printf("YES\n");        else            printf("NO\n");    }    return 0;}</stdio.h></string.h></iostream></algorithm>
登入後複製

Bob and math problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 456    Accepted Submission(s): 169


Problem Description

Recently, Bob has been thinking about a math problem.
There are 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 be an odd Integer.
  • 2. there is no leading zero.
  • 3. find the biggest one which is satisfied 1, 2.

  • Example:
    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".

     


    Input

    There are multiple test cases. Please process till EOF.
    Each case starts with a line containing an integer N ( 1 The second line contains N Digits which indicate the digit $a_1, a_2, a_3, \cdots, a_n. ( 0 \leq a_i \leq 9)$.

     


    Output

    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.

     


    Sample Input

                          <p class="sycode">                          30 1 335 4 232 4 6                      </p>
    登入後複製

     


    Sample Output

                          <p class="sycode">                          301425-1                      </p>
    登入後複製

     


    Source

    BestCoder Round #11 (Div. 2)

     


    Recommend

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

     

    题意:

    给你n个数字要你组成 n位数的最大的一个奇数。不行就输出-1.

    思路:

    开始读错题意了。以为输出的不一定要用到所有数字。于是判完后就挂了。真搞不懂怎么过开始的数据的。。。

    这题贪心构造就行了。先找一个最小的奇数来做个位如果没有的话就-1。然后把剩下的数排序。如果剩下的还有数字且最大的为0的话肯定输出-1了。不是的话就按降序输出在加上那会找的奇数就行了。

    详细见代码:

    #include<algorithm>#include<iostream>#include<string.h>#include<stdio.h>using namespace std;const int INF=0x3f3f3f3f;const int maxn=100010;typedef long long ll;int arr[150],brr[150];int main(){    int n,i,p,ct;    while(~scanf("%d",&n))    {        ct=0,p=-1;        for(i=0;i<n scanf if p="i;" printf continue for brr sort>=0;i--)            printf("%d",brr[i]);        printf("%d\n",arr[p]);    }    return 0;}</n></stdio.h></string.h></iostream></algorithm>
    登入後複製

    Boring count Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 250    Accepted Submission(s): 98


    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 1 1

     


    Output

    For each case, output a line contains the answer.

     


    Sample Input

                          <p class="sycode">                          3abc1abcabc1abcabc2                      </p>
    登入後複製

     


    Sample Output

                          <p class="sycode">                          61521                      </p>
    登入後複製

     


    Source

    BestCoder Round #11 (Div. 2)

     


    Recommend

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

     

    题意:

    给你一个长度不超过1e5由小写组成的字符串。问你它有多少个子串。满足子串的每个字符出现的次数都不超过k。

    思路:

    对于一个满足条件的左端点le。把右端点ri的字符一个一个的加进去。如果还是满足条件。这个新加进的字符将会贡献ri-le+1个以该子符为右端点的子串。如果不满足条件了就左移le指针知道满足条件即可。比赛时早就想到思路了。可各种逻辑错误1小时+才1A。

    详细见代码:

    #include<algorithm>#include<iostream>#include<string.h>#include<stdio.h>using namespace std;const int INF=0x3f3f3f3f;const int maxn=100002;typedef long long ll;char txt[maxn];int vis[27];ll ans=0;int main(){    int t,n,k,le,ri,p;    scanf("%d",&t);    while(t--)    {        scanf("%s%d",txt,&k);        n=strlen(txt);        ans=le=ri=0;        memset(vis,0,sizeof vis);        p=-1;        while(rik)                    p=ri;                else if(ri<n ans ri else vis if p="-1,ans+=ri-le-1;" le printf return>    <br> Argestes and Sequence    <strong>Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)<br> Total Submission(s): 192    Accepted Submission(s): 44<br> </strong>    <br>    <br>    <p class="sycode">     Problem Description    </p>    <p class="sycode">     Argestes has a lot of hobbies and likes solving query problems especially. One day Argestes came up with such a problem. You are given a sequence a consisting of N nonnegative integers, a[1],a[2],...,a[n].Then there are M operation on the sequence.An operation can be one of the following:     <br> S X Y: you should set the value of a[x] to y(in other words perform an assignment a[x]=y).     <br> Q L R D P: among [L, R], L and R are the index of the sequence, how many numbers that the Dth digit of the numbers is P.     <br> Note: The 1st digit of a number is the least significant digit.    </p>    <p class="sycode">          </p>    <br>    <p class="sycode">     Input    </p>    <p class="sycode">     In the first line there is an integer T , indicates the number of test cases.     <br> For each case, the first line contains two numbers N and M.The second line contains N integers, separated by space: a[1],a[2],...,a[n]?initial value of array elements.     <br> Each of the next M lines begins with a character type.     <br> If type==S,there will be two integers more in the line: X,Y.     <br> If type==Q,there will be four integers more in the line: L R D P.     <br>     <br> [Technical Specification]     <br> 1 1 0 1 0 1 1 0    </p>
    <p class="sycode">          </p>    <br>    <p class="sycode">     Output    </p>    <p class="sycode">     For each operation Q, output a line contains the answer.    </p>    <p class="sycode">          </p>    <br>    <p class="sycode">     Sample Input    </p>    <p class="sycode">     </p>
    <pre class="brush:php;toolbar:false">                      <p class="sycode">                          15 710 11 12 13 14Q 1 5 2 1Q 1 5 1 0Q 1 5 1 1Q 1 5 3 0Q 1 5 3 1S 1 100Q 1 5 3 1                      </p>
    登入後複製

     


    Sample Output

                          <p class="sycode">                          511501                      </p>
    登入後複製

     


    Source

    BestCoder Round #11 (Div. 2)

     


    Recommend

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

     

    题意:

    给你一个长度不超过1e5的数列。你可以进行两种操作。

    1.S x y。把第x个数变成y。

    2.Q l r d p 。询问[l,r]中数的第d个数字是p的有多少个。

    思路:
    看到这题。喜出望外。今天是可以ak的节奏啊。(不知道1002会挂。。--||)。感觉典型线段树的应用。每个节点一个数组val[rt][i][j]。表示节点代表的区间里第i个数字为j的有多少个。然后欢快的写完了。写完编译运行一次通过。无任何错误和警告测样例完全正确!然后愉快的交了。然后就mle了。。。当时就傻了。一看题目内存限制。晕。居然有数据结构题目卡内存的。然后想了下树状数组开1e7空间就算是short也超了,但是想到了离线处理每一位的修改和询问。但这时已经20:20。依稀的记得20:30就要开hack了。就放弃了挣扎了。后来醒悟后还是没时间改了。虽然正解有我说的离线处理。但是总觉得还是蛮麻烦的就用分块写了。就是分成sqrt(n)块。块内直接暴力。块间利用整块信息维护快速算出答案。时间复杂度O(n*sqrt(n))。写完一交居然rank1.估计O(10*n*log(n))的做法常数太大了。

    详细见代码:

    #include<algorithm>#include<iostream>#include<string.h>#include<stdio.h>#include<math.h>using namespace std;const int INF=0x3f3f3f3f;const int maxn=100003;typedef long long ll;#define lson L,mid,ls#define rson mid+1,R,rsint val[maxn][11],da[400][11][10],x;int main(){    int t,n,m,i,j,le,ri,d,p,x,y,bk,ans,st,ed,lim;    char cmd[10];    scanf("%d",&t);    while(t--)    {        scanf("%d%d",&n,&m);        bk=ceil(sqrt(1.0*n));        memset(da,0,sizeof da);        memset(val,0,sizeof val);        for(i=1;i    <br>    <br>      </math.h></stdio.h></string.h></iostream></algorithm>
    登入後複製
    本網站聲明
    本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

    熱AI工具

    Undresser.AI Undress

    Undresser.AI Undress

    人工智慧驅動的應用程序,用於創建逼真的裸體照片

    AI Clothes Remover

    AI Clothes Remover

    用於從照片中去除衣服的線上人工智慧工具。

    Undress AI Tool

    Undress AI Tool

    免費脫衣圖片

    Clothoff.io

    Clothoff.io

    AI脫衣器

    Video Face Swap

    Video Face Swap

    使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

    熱工具

    記事本++7.3.1

    記事本++7.3.1

    好用且免費的程式碼編輯器

    SublimeText3漢化版

    SublimeText3漢化版

    中文版,非常好用

    禪工作室 13.0.1

    禪工作室 13.0.1

    強大的PHP整合開發環境

    Dreamweaver CS6

    Dreamweaver CS6

    視覺化網頁開發工具

    SublimeText3 Mac版

    SublimeText3 Mac版

    神級程式碼編輯軟體(SublimeText3)

    為何在Go語言中難以實現類似集合的功能? 為何在Go語言中難以實現類似集合的功能? Mar 24, 2024 am 11:57 AM

    在Go語言中難以實現類似集合的功能,是困擾許多開發者的問題。相較於其他程式語言如Python或Java,Go語言並沒有內建的集合類型,如set、map等,這給開發者在實作集合功能時帶來了一些挑戰。首先,讓我們來看看為何在Go語言中難以直接實現類似集合的功能。在Go語言中,最常用的資料結構是slice(切片)和map(映射),它們可以完成類似集合的功能,但

    如何優化Java集合排序效能 如何優化Java集合排序效能 Jun 30, 2023 am 10:43 AM

    Java是一種功能強大的程式語言,廣泛應用於各類軟體開發。在Java開發中,經常會涉及到對集合進行排序的場景。然而,如果不對集合排序進行效能最佳化,可能會導致程式的執行效率下降。本文將探討如何優化Java集合排序的效能。一、選擇適當的集合類別在Java中,有多種集合類別可以用來進行排序,如ArrayList、LinkedList、TreeSet等。不同的集合類別在

    C#中常見的並發集合和線程安全問題 C#中常見的並發集合和線程安全問題 Oct 09, 2023 pm 10:49 PM

    C#中常見的並發集合和執行緒安全問題在C#程式設計中,處理並發操作是非常常見的需求。當多個執行緒同時存取和修改相同資料時,就會出現線程安全性問題。為了解決這個問題,C#提供了一些並發集合和線程安全的機制。本文將介紹C#中常見的並發集合以及如何處理線程安全問題,並給出具體的程式碼範例。並發集合1.1ConcurrentDictionaryConcurrentDictio

    Laravel 集合中的 Where 方法實用指南 Laravel 集合中的 Where 方法實用指南 Mar 10, 2024 pm 04:36 PM

    Laravel集合中的Where方法實用指南在Laravel框架的開發過程中,集合(Collection)是一個非常有用的資料結構,它提供了豐富的方法來操作資料。其中,Where方法是常用的篩選方法,能夠根據指定條件來過濾集合中的元素。本文將介紹Laravel集合中Where方法的使用,透過具體的程式碼範例來示範其用法。 1.基本用法Where方法的

    php中的round是什麼意思 php中的round是什麼意思 Mar 10, 2023 am 10:04 AM

    在php中,round的意思為“四捨五入”,是一個內建函數,作用是將浮點數轉換為整數;該函數可以對浮點數進行四捨五入,並返回一個float類型的整數值,語法“round(number, precision,mode);」。

    如何用PHP的round()函數除以四捨五入 如何用PHP的round()函數除以四捨五入 Mar 21, 2023 pm 04:32 PM

    round() 函數是PHP數字格式化函式庫中一個非常實用的函數,可以將浮點數四捨五入到指定的小數位數。但是,由於PHP的除法運算可能會出現無限小數或精度遺失的問題,因此對除數進行四捨五入也很必要。接下來,我們會詳細講解如何使用PHP的round()函數進行除以四捨五入。

    使用HashSet類別的addAll()方法將一個集合中的所有元素加入到另一個集合中 使用HashSet類別的addAll()方法將一個集合中的所有元素加入到另一個集合中 Jul 24, 2023 am 08:58 AM

    使用HashSet類別的addAll()方法將一個集合中的所有元素加入到另一個集合中HashSet是Java集合框架中的一個實作類,它繼承自AbstractSet,並實作了Set介面。 HashSet是一個基於哈希表的無序集合,其中不允許包含重複的元素。它提供了許多常用的方法來操作集合中的元素,其中之一就是addAll()方法。 addAll()方法的作用是將指定

    Java Iterator 與 Iterable:邁入編寫優雅程式碼的行列 Java Iterator 與 Iterable:邁入編寫優雅程式碼的行列 Feb 19, 2024 pm 02:54 PM

    Iterator介面Iterator介面是一個用於遍歷集合的介面。它提供了幾個方法,包括hasNext()、next()和remove()。 hasNext()方法傳回布林值,指示集合中是否還有下一個元素。 next()方法傳回集合中的下一個元素,並將其從集合中刪除。 remove()方法從集合中刪除目前元素。以下程式碼範例示範如何使用Iterator介面來遍歷集合:Listnames=Arrays.asList("John","Mary","Bob");Iterator

    See all articles