A. Ehab Fails to Be Thanos
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int N; int a[maxn]; int main() { scanf("%d", &N); for(int i = 0; i < N * 2; i ++) scanf("%d", &a[i]); sort(a, a + N * 2); long long sum1 = 0, sum2 = 0; for(int i = 0; i < N; i ++) sum1 += a[i]; for(int i = N; i < N * 2; i ++) sum2 += a[i]; if(sum1 != sum2) { for(int i = 0; i < N * 2; i ++) printf("%d%s", a[i], i != 2 * N - 1 ? " " : " "); } else printf("-1 "); return 0; }
B. Ehab Is an Odd Person
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int N; int odd = 0, even = 0; long long a[maxn]; int main() { scanf("%d", &N); for(int i = 0; i < N; i ++) { scanf("%lld", &a[i]); if(a[i] % 2 == 0) even ++; else odd ++; } if(odd && even) sort(a, a + N); for(int i = 0; i < N; i ++) printf("%lld%s", a[i], i != N - 1 ? " " : " "); return 0; }
C. Ehab and a Special Coloring Problem
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int N; int pos[maxn]; bool isprime(int x) { if(x <= 1) return false; if(x == 2) return true; for(int i = 2; i * i <= x; i ++) { if(x % i == 0) return false; } return true; } void solve() { int p = 1; for(int i = 2; i <= N; i ++) { if(isprime(i)) { pos[i] = p; for(int j = i; j < maxn; j += i) pos[j] = p; p ++; } } } int main() { scanf("%d", &N); solve(); for(int i = 2; i <= N; i ++) printf("%d%s", pos[i], i != N ? " " : " "); return 0; }
D. Ehab and the Expected XOR Problem
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include <bits/stdc++.h> using namespace std; const int maxn = (1 << 18) + 10; int N, x; int vis[maxn]; vector<int> ans; int main() { scanf("%d%d", &N, &x); for(int i = 0; i < 1 << N; i ++) { if(!vis[i]) vis[i ^ x] = 1; } int t = 0; for(int i = 1; i < 1 << N; i ++) { if(!vis[i]) { ans.push_back(t ^ i); t = i; } } printf("%d ", (int)ans.size()); for(int i = 0; i < (int)ans.size(); i ++) printf("%d%s", ans[i], i != (int)ans.size() - 1 ? " " : " "); return 0; }
开始营业辣 是顶着太阳来公司加班的一天了!