Codeforces Round #563 (Div. 2)/CF1174
Codeforces Round #563 (Div. 2)/CF1174
CF1174A Ehab Fails to Be Thanos
其实就是要\(\sum\limits_{i=1}^n a_i\)与\(\sum\limits_{n+1}^{2n}a_i\)差值最大,排一下序就好了
CF1174B Ehab Is an Odd Person
一个显然的结论就是如果至少有一个奇数和一个偶数,那么是可以随意调整的,也就是升序排序
否则不可以进行任何操作
CF1174C Ehab and a Special Coloring Problem
与\(x\)互质的数填不同的数,把有向关系表示出来,发现边数是不能承受的
反过来想,成倍数关系填相同的数,把这些数想象成一条链,而这条链开始的数一定是质数,\(\sum\limits_{prime_i}\frac{n}{prime_i}\)是可以承受的
把这条链的点赋一个相同的值
CF1174D Ehab and the Expected XOR Problem
求出答案序列的异或前缀和\(sum_i\),\([l,r]\)子段异或和可表示为\(sum_r\bigoplus sum_{l-1}\)
故转换问题为,填\(sum\)数组,数组内的元素不为\(0\)且互不相同,且两两异或不为\(x\)
预处理\(x\)为多对值,每对值异或起来为\(x\),显然是两两互不影响的,每对值选择任意一个填就行了
最后还得从\(sum_i=\bigoplus_{j=1}^i a_i\)转换为\(a_i\)
CF1174E Ehab and the Expected GCD Problem
先来填第一个数,为了保证\(f(p)\)最大,第一个数分解一下为\(\prod\limits_{p_i}p_i^{k_i}\)使得\(\sum\limits_{k_i}\)最大
显然第一个数为\(2^x3^y\)且\(y≤1\),否则可以把\(3^2\)换成\(2^3\),故第一个数最多有两种选择
定义函数\(Cout(x,y)=\frac{n}{2^x3^y}\)为n以内含因子\(2^x3^y\)的个数
设\(f_{i,x,y}\)为填到第\(i\)个数后\(gcd_{j=1}^i a_i=2^x3^y\)的方案数,显然最后的答案为\(f_{n,0,0}\)
CF1174F Ehab and the Big Finale
\(x\)为隐藏节点,\(dep_x=d(1,x)\)
\((1)\):\(u=1\)
\((2)\):重链剖分,比如\(v\)为\(u\)的重链底部,查询\(dis(x,v)\)的长度,\(y=lca(v,x)\)且在重链上,\(dis(x,v)=dep_v+dep_x-2*dep_y,dep_y=(dep_v+dep_x-dis(x,v))/2\),则我们可以找到\(y\)
\((3)\):但\(dep_y=dep_x\)时,\(y\)为答案,退出
\((4)\):找到\(y\)后,查询\(sec=(y,x)\)上的第二个节点,\(u=sec\)返回\((2)\)
Codeforces Round #563 (Div. 2)/CF1174的更多相关文章
- Codeforces Round #563 (Div. 2) C. Ehab and a Special Coloring Problem
链接:https://codeforces.com/contest/1174/problem/C 题意: You're given an integer nn. For every integer i ...
- Codeforces Round #563 (Div. 2) B. Ehab Is an Odd Person
链接:https://codeforces.com/contest/1174/problem/B 题意: You're given an array aa of length nn. You can ...
- Codeforces Round #563 (Div. 2) A. Ehab Fails to Be Thanos
链接:https://codeforces.com/contest/1174/problem/A 题意: You're given an array aa of length 2n2n. Is it ...
- Codeforces Round #563 (Div. 2)C
C. Ehab and a Special Coloring Problem 题目链接:http://codeforces.com/contest/1174/problem/C 题目 You're g ...
- Codeforces Round #563 (Div. 2)B
B.Ehab Is an Odd Person 题目链接:http://codeforces.com/contest/1174/problem/B 题目 You’re given an array a ...
- Codeforces Round #563 (Div. 2)A
A. Ehab Fails to Be Thanos 题目链接:http://codeforces.com/contest/1174/problem/A 题目 You’re given an arra ...
- Codeforces Round #563 (Div. 2) E. Ehab and the Expected GCD Problem
https://codeforces.com/contest/1174/problem/E dp 好题 *(if 满足条件) 满足条件 *1 不满足条件 *0 ///这代码虽然写着方便,但是常数有点大 ...
- Codeforces Round #563 (Div. 2) F. Ehab and the Big Finale
后续: 点分治标程 使用father数组 比使用vis数组优秀(不需要对vis初始化) https://codeforces.com/problemset/problem/1174/F https:/ ...
- Codeforces Round 563 (Div. 2) 题解
自己开了场镜像玩. 前三题大水题.D有点意思.E完全不会.F被题意杀了……然而还是不会. 不过看过(且看懂)了官方题解,所以这里是六题题解齐全的. A 水题.给原序列排序,如果此时合法则直接输出,否则 ...
随机推荐
- Asp.net Core 2.0 OpenId Connect Handler缺失Claims?
原文:https://leastprivilege.com/2017/11/15/missing-claims-in-the-asp-net-core-2-openid-connect-handler ...
- vue 后台管理系统菜单权限管理
来自:https://www.cnblogs.com/fqh123/p/11094296.html 侵删 login登录方法 login() { if (!this.username) { retur ...
- echarts3关系图:力引导布局, 固定某些节点
在数组里设置 fixed: true,<a href='http://echarts.baidu.com/option.html#series-graph.data.fixed'>官方文档 ...
- TLS1.3 握手协议的分析
1.LTS支持的三种基本的密码交换模式 (EC)DHE (Diffie-Hellman both the finte field and ellptic curve varieties) PSK-on ...
- C++——inline function
前言 当代码写复杂后,一定会封装出大量的函数,这会导致两个问题: ①函数越多,栈的消耗也越厉害 疑问:为什么代码复杂了.函数变多了,栈消耗的就很厉害? 答:因为这会导致函数的调用深度可能会很深,比如: ...
- js依赖mui.css生成图片验证码
js依赖mui.css生成图片验证码 相关css和js引入路径 https://cdnjs.cloudflare.com/ajax/libs/mui/3.7.1/css/mui.css https:/ ...
- python数据类型:dict(字典)
一.字典的简单介绍 字典(dict)是python中唯一的一个映射类型.他是以{}括起来的键值对组成. 语法: {key1:value1,key2:value2......} 注意:key必须是不可变 ...
- ReLU激活函数
参考:https://blog.csdn.net/cherrylvlei/article/details/53149381 首先,我们来看一下ReLU激活函数的形式,如下图: 单侧抑制,当模型增加N层 ...
- c++ vector容器基本用法
基本用法 #include<iostream> #include<string> #include<vector> using namespace std; cla ...
- Android --其他测试点
全球化测试: 语言方向,参考:https://developer.android.google.cn/guide/topics/resources/pseudolocales. Spot locali ...