#include<iostream> usingnamespacestd; #define LL long long LL a, b, c, d, x, y; intmain() { cin >> a >> b >> c >> d; x = max(a * c, a * d), y = max(b * c, b * d); cout << max(x, y); }
C. Ubiquity
简单容斥一下即可。
1 2 3 4 5 6 7 8 9 10 11 12
#include<iostream> usingnamespacestd; constint P = 1e9 + 7; intqp(int a,int b){int r = 1; while(b) {if(b & 1) r = 1ll * r * a % P; a = 1ll * a * a % P; b >>= 1;} return r;} int n; intmain() { cin >> n; int ans = qp(10, n), k = 2ll * qp(9, n) % P; ans = (ans - k + P) % P, k = qp(8, n), ans = (ans + k) % P; cout << ans; }
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<set> usingnamespacestd; constint CN = 2e5 + 5; intread(){ int s = 0,ne = 1; char c = getchar(); while(c < '0' || c > '9') ne = c == '-' ? -1 : 1, c = getchar(); while(c >= '0' && c <= '9') s = (s << 1) + (s << 3) + c - '0', c = getchar(); return s * ne; } int n, a[CN], b[CN]; int cnt[CN]; set<int, greater<int> > S; intmain() { n = read(); for(int i = 1; i <= n; i++) a[i] = read(); for(int i = 1; i <= n; i++) b[i] = read(), S.insert(b[i]), cnt[ b[i] ]++; memset(b, 0, sizeof(b));
bool flag = true; for(int i = 1; i <= n && flag; i++){ bool has = false; for(set<int> :: iterator it = S.begin(); it != S.end(); it++){ int val = *it; if(val ^ a[i]){ b[i] = val, has = true, cnt[val]--; if(!cnt[val]) S.erase(it); break; } } flag &= has; }
if(!flag) puts("No"); else{ puts("Yes"); for(int i = 1; i <= n; i++) printf("%d ", b[i]); } }