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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

codeforces Round#429 (Div2)

發布時間:2025/5/22 编程问答 16 豆豆
生活随笔 收集整理的這篇文章主要介紹了 codeforces Round#429 (Div2) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2017-08-20?10:00:37

writer:pprp

用頭文件#include <bits/stdc++.h>很方便

A. Generous Kefa codeforces 841 A

題目如下:

One day Kefa found?n?baloons. For convenience, we denote color of?i-th baloon as?si?— lowercase letter of the Latin alphabet. Also Kefa has?k?friends. Friend will be upset, If he get two baloons of the same color. Kefa want to give out?all?baloons to his friends. Help Kefa to find out, can he give out all his baloons, such that no one of his friens will be upset — print ?YES?, if he can, and ?NO?, otherwise. Note, that Kefa's friend will not upset, if he doesn't get baloons at all.

Input

The first line contains two integers?n?and?k?(1?≤?n,?k?≤?100) — the number of baloons and friends.

Next line contains string?s?— colors of baloons.

Output

Answer to the task — ?YES? or ?NO? in a single line.

You can choose the case (lower or upper) for each letter arbitrary.

Examples input 4 2
aabb output YES input 6 3
aacaab output NO

統計某個字符數量是否超過給定人數即可(水題) #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring>using namespace std;char ch[110]; int num[110]; int Max = -9999; int buck[30];int main() {int n, k;cin >> n >> k;memset(num, 0 , sizeof(num));memset(buck, 0, sizeof(num));for(int i = 0 ; i < n ; i++){cin >> ch[i];num[i] = ch[i] - 'a';}for(int i = 0 ; i < n ;i++){buck[num[i] ]++;}for(int i = 0 ; i < 30 ; i++){if(Max < buck[i])Max = buck[i];}if(Max > k)cout << "NO" << endl;elsecout << "YES" << endl;return 0; }

?

B. Godsend?codeforces 841B

題目如下:

Leha somehow found an array consisting of?n?integers. Looking at it, he came up with a task. Two players play the game on the array. Players move one by one. The first player can choose for his move a subsegment of non-zero length with an odd sum of numbers and remove it from the array, after that the remaining parts are glued together into one array and the game continues. The second player can choose a subsegment of non-zero length with an even sum and remove it. Loses the one who can not make a move. Who will win if both play optimally?

Input

First line of input data contains single integer?n?(1?≤?n?≤?106) — length of the array.

Next line contains?n?integers?a1,?a2,?...,?an?(0?≤?ai?≤?109).

Output

Output answer in single line. "First", if first player wins, and "Second" otherwise (without quotes).

Examples input 4
1 3 2 3 output First input 2
2 2 output Second

分析:找規律的題目,經過多次舉例可以看出 單數占優勢, 偶數占劣勢
所以僅需要判斷是否一開始就是偶數就可以,注意要用scanf 不要用 cin
AC代碼如下: #include <iostream> #include <cstring> #include <cstdio>using namespace std; typedef long long ll;int main() {int n;ll tmp;scanf("%d",&n);int cntodd = 0;int cnteven = 0;for(int i = 0 ; i < n; i++){scanf("%lld",&tmp);if(tmp & 1)cntodd++;elsecnteven++;}if(cntodd == 0)cout << "Second" << endl;elsecout << "First" << endl;return 0; }

?codeforce 841 C

C. Leha and Function

題目如下:

Leha like all kinds of strange things. Recently he liked the function?F(n,?k). Consider all possible?k-element subsets of the set[1,?2,?...,?n]. For subset find minimal element in it.?F(n,?k)?— mathematical expectation of the minimal element among all?k-element subsets.

But only function does not interest him. He wants to do interesting things with it. Mom brought him two arrays?A?and?B, each consists ofm?integers. For all?i,?j?such that?1?≤?i,?j?≤?m?the condition?Ai?≥?Bj?holds. Help Leha rearrange the numbers in the array?A?so that the sum??is maximally possible, where?A'?is already rearranged array.

Input

First line of input data contains single integer?m?(1?≤?m?≤?2·105) — length of arrays?A?and?B.

Next line contains?m?integers?a1,?a2,?...,?am?(1?≤?ai?≤?109) — array?A.

Next line contains?m?integers?b1,?b2,?...,?bm?(1?≤?bi?≤?109) — array?B.

Output

Output?m?integers?a'1,?a'2,?...,?a'm?— array?A'?which is permutation of the array?A.

Examples input 5
7 3 5 3 4
2 1 3 2 3 output 4 7 3 5 3 input 7
4 6 5 8 8 2 6
2 1 2 2 1 1 2 output 2 6 4 5 8 8 6

題意很不好理解,觀察數據以后發現所謂的期望就是幾分之幾?

比如: 第一個例子中

7 3 5 3 4

2 1 3 2 3

期望為:2 / 7 + 1 / 3 + 3 / 5 + 2 / 3 + 3 / 4

題目要求期望最大值,那么要將分子中最小的與分母中最大的進行匹配

比較坑的一點是,如果分子相同,那么該如何處理?

本來以為應該從小到大排序,但是之后看的時候并沒有要求怎么排序

所以用sort pair就可以解決了

一開始本來想用multimap來著,但是沒有必要

用pair進行排序就可以了,sort只能排序線性的容器,所以也不能對map進行排序(雖然map中按key已經排好了)

代碼如下:

#include<bits/stdc++.h>using namespace std;int n;pair<int, int> a[200008]; pair<int, int> b[200008];int ansa[200008];int main() {cin >> n;for (int i = 0; i < n; i++) {cin >> a[i].first;a[i].second = i;}for (int i = 0; i < n; i++) {cin >> b[i].first;b[i].second = i;}sort(a, a + n);sort(b, b + n);for (int i = 0; i < n; i++) {ansa[b[i].second] = a[n - 1 - i].first;}for (int i = 0; i < n; i++) {printf("%d ", ansa[i]);}return 0; }

?

?

轉載于:https://www.cnblogs.com/pprp/p/7399073.html

總結

以上是生活随笔為你收集整理的codeforces Round#429 (Div2)的全部內容,希望文章能夠幫你解決所遇到的問題。

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

主站蜘蛛池模板: 日韩性xxx | 久久国语精品 | 国产一区亚洲二区三区 | 亚洲成人99| 中文字幕亚洲一区二区三区五十路 | 亚洲片国产一区一级在线观看 | 国产欧美精品一区二区色综合 | 小视频成人 | 日本精品视频网站 | 激情婷 | 国产欧美一区二区三区在线看 | 国产三级三级在线观看 | 欧美黑人精品一区二区不卡 | 91精品91| 欧美91视频| 国产白浆视频 | 在线天堂中文在线资源网 | 国产成人精品999在线观看 | 色欲久久久天天天综合网精品 | 黄色大片儿. | 男女羞羞无遮挡 | 亚洲精品www久久久久久 | 91香蕉视频污污 | 亚洲福利网站 | 成年人视频免费看 | 91中文字幕在线观看 | 国产黄色a | 欧美色图第一页 | 国产精品九九九九九 | 亚洲色吧| 大地资源在线观看免费高清版粤语 | 美女涩涩视频 | jlzzjlzz亚洲女人18| 午夜免费播放观看在线视频 | 一区二区三区欧美日韩 | 欧美自偷自拍 | 日本一区精品视频 | 久久久久一区 | 美女被男人桶出白浆喷水 | jizzzz中国 | 成都免费高清电影 | 国产乱码久久久久 | 亚洲欧美综合色 | 精品人妻二区中文字幕 | 成人爱爱网站 | 国产精品污网站 | 69社| 老汉av | 日韩女同一区二区三区 | 在线看毛片网站 | 国产深喉视频一区二区 | 永久在线视频 | 国产精品久久久久久久av福利 | 免费国产高清 | 欧美精品v国产精品v日韩精品 | 免费在线观看av片 | 91成人免费在线视频 | 日韩高清不卡一区 | 国产成人无码久久久精品天美传媒 | 51成人网| 色丁香av | 香蕉视频在线播放 | 国产精品视频你懂的 | 色性网 | 精品久久久久亚洲 | 精品日本视频 | 在线视频午夜 | 久久婷婷一区二区 | 大肉大捧一进一出好爽视频 | 久久精品偷拍视频 | 好吊妞一区二区三区 | 丁香婷婷一区二区三区 | 成人免费入口 | 成人综合一区二区 | 邻居校草天天肉我h1v1 | 亚洲免费色图 | 国产精品国产精品国产专区 | 色图18p | 久久人人爽人人爽人人片av免费 | 天天干网 | 色综合色综合色综合 | 亚洲在线网站 | 国模视频一区二区 | 综合久久婷婷 | 欧美伦理一区二区三区 | 久久黄色片 | 久久久久激情 | 中文在线字幕免费观 | 日本黄色美女视频 | 精品国产av 无码一区二区三区 | 色播在线观看 | 一本一本久久a久久精品综合麻豆 | 欧美乱码精品 | 亲子伦视频一区二区三区 | 久久理论视频 | 男人和女人插插 | 免费av不卡在线观看 | www.九色| 非洲黑寡妇性猛交视频 |