日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

CodeForce 534C Polycarpus' Dice (数学推理)

發布時間:2025/3/16 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CodeForce 534C Polycarpus' Dice (数学推理) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Polycarpus' Dice time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output

Polycarp has?n?dice?d1,?d2,?...,?dn. The?i-th dice shows numbers from?1?to?di. Polycarp rolled all the dice and the sum of numbers they showed is?A. Agrippina didn't see which dice showed what number, she knows only the sum?A?and the values?d1,?d2,?...,?dn. However, she finds it enough to make a series of statements of the following type: dice?i?couldn't show number?r. For example, if Polycarp had two six-faced dice and the total sum is?A?=?11, then Agrippina can state that each of the two dice couldn't show a value less than five (otherwise, the remaining dice must have a value of at least seven, which is impossible).

For each dice find the number of values for which it can be guaranteed that the dice couldn't show these values if the sum of the shown values is?A.

Input

The first line contains two integers?n,?A?(1?≤?n?≤?2·105,?n?≤?A?≤?s) — the number of dice and the sum of shown values where?s?=?d1?+?d2?+?...?+?dn.

The second line contains?n?integers?d1,?d2,?...,?dn?(1?≤?di?≤?106), where?di?is the maximum value that the?i-th dice can show.

Output

Print?n?integers?b1,?b2,?...,?bn, where?bi?is the number of values for which it is guaranteed that the?i-th dice couldn't show them.

Sample test(s) input 2 8 4 4 output 3 3 input 1 3 5 output 4 input 2 3 2 3 output 0 1 Note

In the first sample from the statement?A?equal to 8 could be obtained in the only case when both the first and the second dice show 4. Correspondingly, both dice couldn't show values 1, 2 or 3.

In the second sample from the statement?A?equal to 3 could be obtained when the single dice shows 3. Correspondingly, it couldn't show 1, 2, 4 or 5.

In the third sample from the statement?A?equal to 3 could be obtained when one dice shows 1 and the other dice shows 2. That's why the first dice doesn't have any values it couldn't show and the second dice couldn't show 3.


題意:給出n個骰子,每個骰子有d[i]個面(點數為1~d[i]),通過搖n個骰子得到一個整數A。求每個骰子不可能出現的點數的個數,即多少個點數不可能出現。
分析:對于一個骰子,先求出其余所有篩子能夠得到的最大值之和和最小值之和,然后根據最大值之和、最小值之和就能求出每個骰子不可能出現的點數。 如果其余所有的骰子都取最小值1,則最小值之和為n-1,當前骰子應取x=A - (n - 1),當前骰子的最大取值就是x,若d[i]>x, 則從x+1~d[i]之間的數都不會取到,共有d[i]-x個;如果其余所有的骰子都去最大值d[i],則最大值之和為sum - d[i],當前骰子的應取y=A - (sum - d[i]),最小取值就是y,若y > 0,則從1~y-1之間的數都不可能取到,共有y-1個;二者加起來就是最終的答案。 #include <cstdio> #include <iostream> #include <cstring> #include <algorithm> using namespace std;typedef long long LL; const int N = 2e5 + 10; LL d[N];int main() {LL n, A;while(cin >> n >> A) {LL sum = 0;for(int i = 0; i < n; i++) {cin >> d[i];sum += d[i];}bool flag = false;for(int i = 0; i < n; i++) {LL ans = 0;LL x = A + 1 - n; //其它骰子都取1,當前骰子最大的取值為xif(d[i] > x) ans += (d[i] - x);LL y = A - (sum - d[i]); //其它骰子都取最大值,當前骰子的最小取值為yif(y > 0) ans += (y - 1);if(flag) cout << " ";cout << ans;flag = true;}cout << endl;}return 0; }

總結

以上是生活随笔為你收集整理的CodeForce 534C Polycarpus' Dice (数学推理)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 亚洲熟女综合色一区二区三区 | 在线免费观看中文字幕 | a级黄色小说 | 九九久久九九久久 | 成人综合区一区 | 深夜福利久久 | 中文字幕av一区二区三区人妻少妇 | 久草视频免费 | 花样视频污| 爱情岛成人 | 国产无套视频 | 黄色一级黄色片 | 黄色茄子视频 | 免费a视频| 成人在线观看www | 亚洲精品视频免费在线观看 | 亚洲一区日韩精品 | 国产香蕉视频在线播放 | 打屁股无遮挡网站 | 怡红院国产 | 国产肉体ⅹxxx137大胆 | 欧美 中文字幕 | 色黄视频网站 | 高h视频在线免费观看 | 国产又粗又猛又爽又黄的视频一 | 色哟哟视频网站 | 日韩专区中文字幕 | 又黄又刺激的视频 | 亚洲av无码一区二区三区网站 | 久久美女视频 | 97夜夜操 | 欧美理论视频 | 久久午夜鲁丝片 | 免费观看a毛片 | 国产一区免费在线 | 调教在线观看 | 色婷婷97 | 欧美日本韩国一区 | 99色热| aaa级片 | 午夜淫片| 荷兰女人裸体性做爰 | 亚洲精品婷婷 | 91精品国产高潮对白 | 720url在线观看免费版 | 国产91久久精品一区二区 | 综合久久久 | 成人在线一区二区三区 | 在线午夜电影 | 国产又大又黄又粗 | 久久无码专区国产精品s | 看全色黄大色黄大片大学生 | 亚色中文字幕 | av老司机在线观看 | 国产伦精品一区二区三区视频黑人 | 欧美日韩性 | 日韩日韩日韩日韩日韩 | 手机亚洲第一页 | 人人草人人射 | 免费在线成人av | 综合性色 | 西西大胆午夜视频 | 人妻天天爽夜夜爽一区二区三区 | 国产一区h| 香蕉婷婷 | 日韩欧美一区在线 | 免费伊人网 | 亚洲福利网站 | 少妇搡bbbb搡bbb搡小说 | 午夜影院一区二区三区 | 免费观看的黄色网址 | 日韩精品综合 | 在线免费av网址 | 999视频 | 91系列在线观看 | 日韩视频第一页 | 久久午夜剧场 | 91免费版黄 | 亚洲av无码一区二区三区四区 | 黄瓜视频成人 | 99热热| av影片在线播放 | 午夜天堂在线观看 | 久久国产精品99久久人人澡 | 一边摸一边抽搐一进一出视频 | 国产sm调教一区二区 | 亚洲精品一线 | 日韩av一区二区三区在线观看 | 国产尤物在线 | 白俄罗斯毛片 | 波多野结av衣东京热无码专区 | 性――交――性――乱睡觉 | 午夜在线网站 | 一区二区免费在线视频 | 美女18网站 | 欧美二区在线 | 人人上人人干 | 1024毛片| 亚洲精品久久久乳夜夜欧美 |