POJ 3507 Judging Olympia

小技巧 判断 全部为零 用sign和所有元素依次取或

排除最大项和最小项 直接排序后取中间的四个元素

http://poj.org/problem?id=3507

 1 #include <iostream>
 2 #include <stdio.h>
 3 #include <algorithm>
 4 using namespace std;
 5
 6 int main()
 7 {
 8     freopen("in.txt", "r", stdin);
 9     int a[6];
10     double sum;
11     bool sign = 0;
12     while (1)
13     {
14         sign = 0;
15         sum = 0;
16         for (int i = 0; i < 6; i++)
17         {
18             cin >> a[i];
19             sign |= a[i];
20         }
21         if (!sign) break;
22         sort(a, a+6);
23         for (int i = 1; i < 5; i++)
24         {
25             sum += a[i];
26         }
27         cout << sum / 4 << endl;
28     }
29     return 0;
30 }
时间: 2024-08-28 10:59:51

POJ 3507 Judging Olympia的相关文章

POJ 1064 Cable master(很好玩的二分搜索)

Cable master Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24292   Accepted: 5200 Description Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised to

POJ 1064 Cable master 浮点数二分

Cable master Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 21181   Accepted: 4571 Description Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised to

(poj)1064 Cable master 二分+精度

题目链接:http://poj.org/problem?id=1064 Description Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised to organize the most honest contest ever. It was decided to conn

POJ 1064 Cable master (二分 分数化整数)

Cable master Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 28764   Accepted: 6091 Description Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised to

poj 1064 (二分+控制精度) &amp;&amp; hdu 1551

链接:http://poj.org/problem?id=1064 Cable master Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 23896   Accepted: 5118 Description Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee ha

poj 1064 Cable master【浮点型二分查找】

Cable master Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 29554   Accepted: 6247 Description Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised to

POJ - 3186 Treats for the Cows (区间DP)

题目链接:http://poj.org/problem?id=3186 题意:给定一组序列,取n次,每次可以取序列最前面的数或最后面的数,第n次出来就乘n,然后求和的最大值. 题解:用dp[i][j]表示i~j区间和的最大值,然后根据这个状态可以从删前和删后转移过来,推出状态转移方程: dp[i][j]=max(dp[i+1][j]+value[i]*k,dp[i][j-1]+value[j]*k) 1 #include <iostream> 2 #include <algorithm&

POJ 2533 - Longest Ordered Subsequence(最长上升子序列) 题解

此文为博主原创题解,转载时请通知博主,并把原文链接放在正文醒目位置. 题目链接:http://poj.org/problem?id=2533 Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the given numeric sequence (a1, a2, ..., aN) be any sequence (ai1, ai2, ..., aiK)

POJ——T2271 Guardian of Decency

http://poj.org/problem?id=2771 Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 5932   Accepted: 2463 Description Frank N. Stein is a very conservative high-school teacher. He wants to take some of his students on an excursion, but he is