#298 (Div.2) C. Polycarpus ' Dice

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.