Best coder 6

Source: Internet
Author: User
Tags cmath

It is said that the best coder really made me feel strange. The first line is wa, and you will know what I was

This is a dilemma.

Let's talk about the second question, I thought like this at the beginning, from 1 to K-2 all assigned to their respective sequence number, that is, 1, 2, 3...

Until the K-2, and then calculate the sum of the previous K-1 item for beg, the sum of the previous K-2 item for beg2;

From beg, until N cycle, find the number I that can fully open, with n-I is the K number, the i-beg2 is

The reciprocal number is 2nd. This is because each number is different. Therefore, you can determine the number by adding a few conditions.

HDU 4981

#include<map>#include<cmath>#include<queue>#include<vector>#include<cstdio>#include<string>#include<cstring>#include<iostream>#include<algorithm>#define inf 0xfffffff#define maxn 1010using namespace std;int array[maxn];int main(){    int sum;    int num,average;    while(scanf("%d",&num)!=EOF)    {        sum=0;        for(int i=1;i<=num;i++)        {            scanf("%d",&array[i]);            sum+=array[i];        }       // printf("%d\n",sum);        average=sum/num;        sort(array+1,array+1+num);        int median;        int mid;        mid=(1+num)/2;        median=array[mid];       // printf("%d %d\n",average,median);        if(average>=median) printf("NO\n");        else printf("YES\n");    }    return 0;}


HDU 4982

#include<map>#include<cmath>#include<queue>#include<vector>#include<cstdio>#include<string>#include<cstring>#include<iostream>#include<algorithm>#define inf 0xfffffff#define maxn 1010using namespace std;int sum,k;int main(){    while(scanf("%d%d",&sum,&k)!=EOF)    {        int beg=k*(k-1)/2;        int beg2=(k-1)*(k-2)/2;        bool flag=0;        for(int i=sum-1;i>=beg;i--)        {            int sq=(int)sqrt(i*1.0);            if(sq*sq!=i) continue;            else            {               int second=i-beg2;               int fin=sum-i;               if(second>k-2)               {                  if(fin>k-2)                    {                       if(fin!=second) flag=1;                       else if(second>k) flag=1;                    }                  else                    {                       second-=(k-1-fin);                       if(second>k-1) flag=1;                    }               }            }        }        if(flag) printf("YES\n");        else printf("NO\n");    }    return 0;}


Leave a message if you have any questions.

Best coder 6

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.