B.Unnatural Conditions
题目链接 :
http://codeforces.com/contest/1028/problem/B
#include<iostream> #include<cstdio> #include<algorithm> #include<cmath> #define lson x<<1 #define rson (x<<1)|1 using namespace std; #define maxn 200010 void Swap(int &a, int &b){ int tmp = a;a = b;b = tmp; } typedef long long ll; int main(){int n, m;cin >> n >> m;for(int i = 1; i <= n; i++) printf("1"); cout << endl; for(int i = 1; i < n; i++)printf("8");cout << "9" << endl;return 0; }
E. Restore Array
题目链接:
http://codeforces.com/contest/1028/problem/E
#include<cstdio> #include<algorithm> using namespace std; int n, pv = -1; long long w[150000], Mx, res[150000], ss, ck = 0; int main() { int i; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%lld", &w[i]); if (Mx < w[i])Mx = w[i]; ss += w[i]; } if (Mx == 0) { puts("YES"); for (i = 0; i < n; i++)printf("%d ", 2); return 0; } for (i = 0; i < n; i++) { if (w[i] != Mx && w[(i + 1) % n] == Mx) { pv = (i + 1) % n; } } if (pv == -1) { puts("NO"); return 0; } res[pv] = Mx; for (i = 0; i < n - 1; i++) { int tpv = pv; pv = (pv + n - 1) % n; if (w[pv] == 0 && !ck) { res[pv] = res[tpv] * 3; ck = 1; } else { res[pv] = res[tpv] + w[pv]; } } puts("YES"); for (i = 0; i < n; i++)printf("%lld ", res[i]); }