2016 Chinese college student Program design Contest-Network Tryouts 1004DANGANRONPA

Source: Internet
Author: User

problem DescriptionChisa Yukizome works as a teacher in the school. She prepares many gifts, which consist ofNKinds witha[i] Quantities of each kind, for she students and wants to the A class meeting. Because of the busy work, she gives his gifts to the monitor, Chiaki Nanami. Due to the strange design of the school, the students ' desks is in a row. Chiaki Nanami wants to arrange gifts like this:

1. Each table would be prepared to a mysterious gift and an ordinary gift.

2. In order to reflect the Chisa yukizome ' s generosity, the kinds of the ordinary gift on the adjacent table must be Diffe Rent.

3. There is no limits for the mysterious gift.

4. The gift must be placed continuously.

She wants to know what many students can get gifts in accordance with her idea at most (suppose the number of students is Infinite). As the most important people of hers, you're easy-to-solve it, aren ' t you?   InputThe first line of input contains an integerT(t≤ten) indicating the number of test cases.

Each case contains one integerN. The next line containsN (1≤n≤) Numbersa1,a2,.. . ,an , (1≤ai≤100000). OutputFor each test case, output one line containing ' case #x: Y ' (without quotes), where x is the ' test Case number (start ing from 1) and Y are the answer of Chiaki Nanami ' s question.
Sample Input 1 2 3 2 Sample Outputcase # 1 2

Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=5835

****************************************************

Test instructions: There is a T set of test instances, each group of instances have n types of gifts, the first type of gift A[i], the next classmate's gift can not be the same, ask how many students can get the gift to meet the requirements.

Analysis: From this problem I learned the importance of the courage to try%>_<%~ brain hole in spite of open, try not to lose AH

This problem does not require children's shoes to sit next to each other, so, sit casually, this shows the god horse, this shows that this is a water problem%>_<%~

Just need to judge a person's gift can divide several people's question ....

Those who are still studying how to sit and get the most results and how to achieve the children's shoes.

1#include <iostream>2#include <cstdio>3#include <cstring>4#include <algorithm>5#include <cmath>6#include <stack>7#include <map>8#include <vector>9 using namespacestd;Ten  One #defineN 12000 A #defineINF 0x3f3f3f3f -  - intA[n]; the  - intMain () - { -     intt,n,i,sum,k=1; +  -scanf"%d", &T); +  A      while(t--) at     { -sum=0; -scanf"%d", &n); -  -          for(i=0; i<n;i++) -         { inscanf"%d", &a[i]); -sum+=A[i]; to         } +  -printf"Case #%d:", k++); the         if(sum==1) *printf"1\n"); $         ElsePanax Notoginsengprintf"%d\n", sum/2); -     } the     return 0; +}

Attach a code that makes it clearer to people who don't understand:

1#include <iostream>2#include <stdio.h>3#include <string.h>4#include <string>5#include <vector>6#include <algorithm>7#include <map>8#include <queue>9#include <stack>Ten#include <math.h> One  A using namespacestd; -  - #defineMet (A, b) memset (A, B, sizeof (a)) the #defineN 53 - #defineINF 0x3f3f3f3f - #definePI 4*atan (1) - Const intMOD =10000007; +  -typedefLong LongLL; +  A intA[n]; at  - intMain () - { -     intT, T =1, n, sum; -scanf"%d", &T); -      while(t--) in     { -sum =0; toscanf"%d", &n); +  -          for(intI=1; i<=n; i++) the         { *scanf"%d", &a[i]); $Sum + =A[i];Panax Notoginseng         } -  theSort (A +1, a+n+1); +          A         intHalf = sum/2; the          +         ints = sum-A[n]; -     $         if(2*s+1<half) $printf"Case #%d:%d\n", t++,2*s+1); -         Else -printf"Case #%d:%d\n", t++, half); the     } -     return 0;Wuyi}

2016 Chinese college student Program design Contest-Network Tryouts 1004DANGANRONPA

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.