-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path168_Pieza_del_puzzle.cpp
87 lines (81 loc) · 2.21 KB
/
168_Pieza_del_puzzle.cpp
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Usuario de Acepta el reto: jjjjjjjp022
#include <stdio.h>
#include <math.h>
// #include <stdlib.h>
// #include <set>
// int main(int argc, char* argv[]) {
// unsigned short int n;
// scanf("%hd", &n);
// while(n != 0) {
// short int present[n+1];
// // std::set<int> present;
// unsigned short int i = 1;
// while(i <= n) {
// present[i] = 0;
// // present.insert(i);
// i++;
// }
// unsigned short int aux;
// i = n;
// while(i-- > 1) {
// scanf("%hd", &aux);
// present[aux] = (short) 1;
// // present.insert(aux);
// }
// // printf("%ld\n", sizeof(present)/sizeof(present[0]));
// // printf("%d\n", *present.cbegin());
// aux = 1;
// // auto it = present.begin();
// while(aux <= n) {
// if(present[aux] == (short)0) {
// printf("%hd\n", aux);
// break;
// }
// // auto it = present.find(aux);
// // if(*it != aux) {
// // printf("%d\n", aux);
// // break;
// // }
// // else {
// // present.erase(it);//Probar poniéndolo y quitándolo
// // }
// aux++;
// // it++;
// }
// // aux = 1;
// // while(aux < sizeof(present)/sizeof(present[0])) {
// // if(present[aux] == 0) {
// // printf("%d\n", aux);
// // break;
// // }
// // aux++;
// // }
// scanf("%hd", &n);
// }
// }
int main(int argc, char* argv[]) {
int n;
scanf("%d", &n);
while(n != 0) {
int total;
if(n%2 == 0) {
total = (n/2)*(n+1);
}
else {
total = ((n+1)/2)*n;
}
// total = n*(1+n)/2;
// (n+n*n)/2
total = n + n*n;
total/=2;
int aux;
// int i = n;
while(n-- > 1) {
scanf("%d", &aux);
total -= aux;
}
// printf("%ld\n", sizeof(present)/sizeof(present[0]));
printf("%d\n", total);
scanf("%d", &n);
}
}