CF488 B.Candy Boxes
数学+暴力
1 #include<iostream> 2 #include<cstdio> 3 #include<cstdlib> 4 #include<cstring> 5 #include<string> 6 #include<queue> 7 #include<algorithm> 8 #include<map> 9 #include<iomanip> 10 #include<climits> 11 #include<string.h> 12 #include<numeric> 13 #include<cmath> 14 #include<stdlib.h> 15 #include<vector> 16 #include<stack> 17 #include<set> 18 #define FOR(x, b, e) for(int x=b;x<=(e);x++) 19 #define REP(x, n) for(int x=0;x<(n);x++) 20 #define INF 1e7 21 #define MAXN 100010 22 #define maxn 1000010 23 #define Mod 1000007 24 #define N 1010 25 using namespace std; 26 typedef long long LL; 27 28 int x[5]; 29 int n; 30 bool gao(int *y) 31 { 32 int cnt = 0; 33 bool vis[4] = {0}; 34 for (int i = 0;i < n;++ i) { 35 for (int j = 0;j < 4;++ j) { 36 if (!vis[j] && y[j] == x[i]) { 37 vis[j] = 1; 38 cnt++; 39 break; 40 } 41 } 42 } 43 if (cnt == n) { 44 puts("YES"); 45 for (int i = 0;i < 4;++ i) 46 if (!vis[i]) cout << y[i] << endl; 47 exit(0); 48 } 49 return false; 50 } 51 52 int main() 53 { 54 cin >> n; 55 for(int i = 0;i < n;++ i) 56 cin >> x[i]; 57 for (int i = 1;i <= 500;++ i) 58 for (int j = i;j <= 2*i ;++ j) { 59 int y[] = {i, j,4*i - j,3*i}; 60 gao(y); 61 } 62 puts("NO"); 63 return 0; 64 }