填寫問券˙抽7-11禮券6檔好股票放一年賺5成輕忽小中風,當心變殘障黃曉明、林志玲攜手代言...
2013-07-10 08:47:19 人氣(3) | 回應(0) | 推薦(0) | 收藏(0) 上一篇 | 下一篇

[UVA] 11348 - Exhibition

0
收藏
0
推薦

I - Exhibition

Time Limit: 1 sec
Memory Limit: 16MB

Some friends have the same hobby, they are collecting stamps. Once upon a time they decided to make an exhibition. Exhibition brought them some money and now they do not know how to divide their income. They decided to divide their money according this rule: "The percent of whole income that i-th friend will get is equal to the part of his unique stamp's type."

The stamp type is called unique if and only if this type of stamps of owned only by one person.

INPUT:

The first line contains integer K (0 < K <= 100), it is number of tests. Each test case is described by positive integer N (0 < N <= 50), it`s the number of friends. Next goes N lines with integers. Each line corresponds one friend stamp collection. The first integer on the line is M - the number of stamps owned by a person (0 < M <= 50). Next goes M integers A (0 <= A <= 10000) - types of stams.

OUTPUT:

For each test case out line formatter like this: "Case i: a1% a2% a3% ... an%". Where "i" is a test number, and "ai" percent of income that goes to i-th friend.

SAMPLE INPUT:

1
3
3 1 2 3
2 4 5
3 4 2 6

SAMPLE OUTPUT:

Case 1: 50.000000% 25.000000% 25.000000%

Problem setters: Aleksej Viktorchik, Leonid Shishlo.
Huge Easy Contest #1

題目不難,但有陷阱,一個人可能擁有多個同一種郵票。

因此在獨特郵票的判定上,要特別小心,只要只有一個人有,他仍是一張獨特的郵票。

#include <stdio.h>
#include <algorithm>
using namespace std;
int main() {
    int testcase, cases = 0;
    int A[50][50], Am[50];
    int n, i, j;
    scanf("%d", &testcase);
    while(testcase--) {
        scanf("%d", &n);
        int mark[10005] = {};
        for(i = 0; i < n; i++) {
            scanf("%d", &Am[i]);
            for(j = 0; j < Am[i]; j++)
                scanf("%d", &A[i][j]);
            sort(A[i], A[i]+Am[i]);
            mark[A[i][0]]++;
            for(j = 1; j < Am[i]; j++)
                if(A[i][j] != A[i][j-1])
                    mark[A[i][j]]++;
        }
        int unique = 0;
        for(i = 0; i <= 10000; i++)
            unique += (mark[i] == 1);
        printf("Case %d:", ++cases);
        for(i = 0; i < n; i++) {
            int cnt = 0;
            cnt += (mark[A[i][0]] == 1);
            for(j = 1; j < Am[i]; j++) {
                if(A[i][j] != A[i][j-1])
                    cnt += (mark[A[i][j]] == 1);
            }
            printf(" %.6lf%%", (double)cnt*100.0/unique);
        }
        puts("");

    }
    return 0;
}

11348Exhibition
台長:Morris
人氣(3) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 不分類 | 個人分類: UVA |
此分類下一篇:[UVA][博弈] 11311 - Exclusively Edible
此分類上一篇:[UVA] 11326 - Laser Pointer

我要回應
是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入以下數字 (ex:123)

(有*為必填)
詳全文