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