首页 > TAG信息列表 > Choosing

CF643G Choosing Ads

传送门 思路 先考虑一下 \(p > 50\) 的情况 这时候就是求“绝对众数” 一个方法就是用“摩尔投票”法 方法就是:每次将不同的两个数去掉,剩下的那种数就是绝对众数(这是保证在有的情况下,才能求出正确的众数) 再考虑 \(20\le p \le 50\) 时,其实我们可以维护 \(\lfloor\frac{p}{100}\rf

L6U6-Choosing a gym

L6U6 Choosing a gym 2022.08.14 Sunday 15:40 - 16:30 this class started? ==>Is this lesson started? How many grades of your college? Freshman sophomore year junior year senior year I graduated five years ago. It's five years since I graduated from

MathProblem 16 Two coins problem

A box contains two coins. One coin is heads on both sides and the other is heads on one side and tails on the other. One coin is selected from the box at random and the face of one side is observed. If the face is heads what is the probability that the ot

hadoop集群一台机器多块磁盘存储不均问题

在hdfs-site.xml 配置文件按下面三个步骤添加参数。添加完同步至datanode节点。 1、数据存储磁盘参数设置多个磁盘目录 剩余磁盘空间大的在前面 <property> <name>dfs.data.dir</name> <value>/data1/dfs/dn,/mnt1/dfs/dn1,/mnt2/dfs/dn</value> </property> 2

CF817E Choosing The Commander 题解

有Q次操作,每次操作有三种类型,分别是 1 pi 把 pi 加入集合 S 2 pi 把 pi 从集合 S 中删除 3 pi li 表示查询集合中有多少个元素异或上 pi 后 小于 li 0/1trie树.显然对于每一位,若这一位异或后比li的这一位小,那么该结点所在的子树异或后都必然小于li,而若与li的这一位相等,则向

D. Choosing Capital for Treeland(树形dp

#include<bits/stdc++.h> using namespace std; const int mod=1000000007; const int N=4e5+10; struct node{ int to,nxt,val; }d[N];int head[N],tot=0; void add(int a,int b,int val){ d[++tot]={b,head[a],val};head[a]=tot; } int f[N],pos=0,MIN=1e9; v

CF817E Choosing The Commander(01Trie)

// Problem: CF817E Choosing The Commander // Contest: Luogu // URL: https://www.luogu.com.cn/problem/CF817E // Memory Limit: 250 MB // Time Limit: 2000 ms // // Powered by CP Editor (https://cpeditor.org) #include<bits/stdc++.h> using namespace st

【CF643G】Choosing Ads(线段树)

点此看题面 给定一个长度为\(n\)的序列和一个整数\(p\)。 要求支持两种操作,区间赋值;询问区间中出现次数至少占\(p\%\)的数,可以输出至多\(\lfloor\frac{100}p\rfloor\)个数,可以包含错解,但必须有正确的解。 \(n\le1.5\times10^5,20\le p\le100\) 前置:一个经典的简单题 一个很简单

D. Choosing Capital for Treeland(思维+换根dp)

https://codeforces.com/problemset/problem/219/D 思路: n^2暴力dfs好写吧。 好写那就改成换根dp。 先dp[u]跑以u为根的子树结果。 再dfs一遍以u为根到整棵树的结果 #include<iostream> #include<vector> #include<queue> #include<cstring> #include<cmath> #include<map> #i

ACM----CodeForces - 1406B Maximum Product

You are given an array of integers

[线段树]CF674 G - Choosing Ads

如果 \(p>50\),那么这个问题就是一个经典的众数问题,有一个 \(O(n)\) 的做法:维护一个二元组 \((w,c)\),遇到一个数 \(x\),若 \(x=w\),++\(c\),否则 --\(c\)。当 \(c\) 恰好减到 \(0\) 时,二元组变为 \((x,1)\) 然后接着做下去,最后二元组里的数 \(w\) 就是众数。因为一个众数抵消一个其他

CF264C Choosing Balls

CF264C Choosing Balls 比较简单就简要说下做法吧: 题面上的翻译现在(10.31)是错的,讨论区那个翻译说得比较清楚转移方程都写上去了 \[\begin{cases} a\times v_{d_i}&i\neq 1\text{且}c_{d_i}=c_{d_{i-1}}\\ b\times v_{d_i}&\text{otherwise} \end{cases} \]设 \(dp_i\) 表示选择 \(

【CodeForces219D】Choosing Capital for Treeland

题目链接 Choosing Capital for Treeland 题目描述 The country Treeland consists of n cities, some pairs of them are connected with unidirectional roads. Overall there are \(n-1\)roads in the country. We know that if we don't take the direction of the roads

Codeforces Round #657 (Div. 2) C. Choosing flowers(贪心/前缀和/二分/枚举)

Vladimir would like to prepare a present for his wife: they have an anniversary! He decided to buy her exactly nn flowers. Vladimir went to a flower shop, and he was amazed to see that there are mm types of flowers being sold there, and there is unlimited

D. Choosing Capital for Treeland(两种树形DP)

A. Drinks Choosing

题目大意是输入n和k,n是学生的数量,k是饮料种类,接下来的n行会输入每个学生想要的饮料的编号(1~k),分配饮料是按一对一对分,每一对都是类型相同的饮料,要去输出能得到自己想要 饮料的最大学生数量   首先定义两种类别,一种是goods类别,比如两个人都想要第1种饮料,那他们就可以被归类为goods

HDU Corn Fields

Problem Description Farmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ≤ 12) square parcels. He wants to grow some yummy corn for the cows on a number of squares. Regrettably, some of the squares are inferti

I.Algorithm Choosing Mushrooms

链接:https://ac.nowcoder.com/acm/contest/908/I 题意: Baby bear and his good friends are very fond of mushrooms. On this day, they go to 402 mushroom field together. Kuangyeye, the owner of the mushroom field, is very happy to see the children. He is going to