-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path10656.cpp
More file actions
56 lines (54 loc) · 1.58 KB
/
Copy path10656.cpp
File metadata and controls
56 lines (54 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Author: btjanaka (Bryon Tjanaka)
// Problem: (UVa) 10656
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORe(i, a, b) for (int i = a; i <= b; ++i)
#define PAI(arr, len) /*Print array of integers*/ \
{ \
for (int _i = 0; _i < len; ++_i) { \
if (_i != len - 1) { \
printf("%d ", arr[_i]); \
} else { \
printf("%d", arr[_i]); \
} \
} \
putchar('\n'); \
}
#define PBS(n, len) /*Print a bitset*/ \
{ \
for (int _i = 0; _i < len; ++_i) { \
putchar(n % 2 + '0'); \
n /= 2; \
} \
putchar('\n'); \
}
#define GET(x) scanf("%d", &x)
#define PLN putchar('\n')
#define INF 2147483647
typedef long long ll;
using namespace std;
// Remember it is sub-sequence, so all we need to do is filter out the positive
// numbers and print them!
int main() {
int n;
while (GET(n) && n) {
bool has_pos = false;
bool first = true;
int x;
FOR(i, 0, n) {
GET(x);
if (x > 0) {
has_pos = true;
if (first) {
printf("%d", x);
first = false;
} else {
printf(" %d", x);
}
}
}
if (!has_pos) printf("0");
PLN;
}
return 0;
}