首爾性愛美術館18禁的藝術老王現身說法關鍵字魅力!吉隆坡最便宜行程一覽表黃國昌嗆周祝瑛 教室一...
2012-05-30 07:42:20 人氣(1,155) | 回應(0) | 推薦(0) | 收藏(0) 上一篇 | 下一篇

[UVA] 11063 - B2-Sequence

0
收藏
0
推薦

Problem H - B2-Sequence

Time Limit: 1 second

A B2-Sequence is a sequence of positive integers 1 ≤ b1 < b2 < b3 ... such that all pairwise sums bi + bj, where i ≤ j, are different.

Your task is to determine if a given sequence is a B2-Sequence or not.

Input

Each test case starts with 2 ≤ N ≤ 100, the number of elements in a sequence. Next line will have N integers, representing the value of each element in the sequence. Each element bi is an integer such that bi ≤ 10000. There is a blank line after each test case. The input is terminated by end of file (EOF).

Output

For each test case you must print the number of the test case, starting from 1, and a message indicating if the corresponding sequence it is a B2-Sequence or not. See the sample output below. After each test case you must print a blank line.

Sample Input

 
4
1 2 4 8
 
4
3 7 10 14
 

Sample Output

 
Case #1: It is a B2-Sequence.
 
Case #2: It is not a B2-Sequence.


#include <stdio.h>

int main() {
int b[1001] = {0}, n, test = 0, i, j;
while(scanf("%d", &n) == 1) {
int flag = 0;
for(i = 1; i <= n; i++) {
scanf("%d", &b[i]);
if(b[i] <= b[i-1]) {
flag = 1;
}
}
int mark[20001] = {};
if(flag == 0)
for(i = 1; i <= n; i++) {
for(j = i; j <= n; j++) {
if(mark[b[i]+b[j]] != 0)
flag = 1;
mark[b[i]+b[j]] = 1;
}
}
printf("Case #%d: It is ", ++test);
if(!flag)
puts("a B2-Sequence.");
else
puts("not a B2-Sequence.");
puts("");
}
return 0;
}

11063B2-Sequence
台長:Morris
人氣(1,155) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 不分類 | 個人分類: UVA |
此分類下一篇:[UVA] 12149 - Feynman
此分類上一篇:[UVA][Greedy] 10718 - Bit Mask

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

(有*為必填)
詳全文