1. Title Description: Click to open the link
2. Problem-Solving ideas: The topic is a math problem, unfortunately in the game did not notice the maximum number of range, and then was hack, instantly rating become unbearable to look straight = =. Just be patient and prepare for the next game. The question asks for the number of numbers that cannot appear in each sieve. can be resolved by determining the boundaries of possible values. Assuming that the sum of the numbers that appear in all sieves is tot, then the maximum range of each sieve is min (A-(n-1), Num[i]), that is, when the other sieve takes 1 o'clock and the smaller of the maximum value of the sieve I itself. The same is not difficult to get the minimum range is max (1,a-(tot-num[i)). In this way, the number of numbers that cannot be seen is num[i]-(maxs-mins+1).
Note: Must be careful examining, pay attention to the maximum data range, the subject to use a long long.
3. Code:
#define _crt_secure_no_warnings #include <iostream> #include <algorithm> #include <string> #include <sstream> #include <set> #include <vector> #include <stack> #include <map> #include < queue> #include <deque> #include <cstdlib> #include <cstdio> #include <cstring> #include < cmath> #include <ctime> #include <functional>using namespace std;typedef long long ll; #define N 200000+ 10int num[n];ll cnt[n];int n;ll a;int Main () {//freopen ("T.txt", "R", stdin), while (~SCANF ("%d%i64d", &n, &a)) {ll tot = 0;for (int i = 0; i < n; i++) {cin >> Num[i];tot + num[i];} for (int i = 0; i < n; i++) {ll maxs = min (A-(n-1), (LL) num[i]);//max. ll mins = max ((ll) 1, A-(tot-num[i]));//min c Nt[i] = num[i]-(maxs-mins + 1);} for (int i = 0; i < n; i++) printf ("%i64d%c", cnt[i], i = = n-1? ' \ n ': ');} return 0;}
#298 (Div.2) C. Polycarpus ' Dice