Codeforces Round #372 (Div. 2)
Codeforces Round #372 (Div. 2)
C. Plus and Square Root
题意
- 一个游戏中,有一个数字\(x\),当前游戏等级为\(k\),有两种操作:
- '+'按钮:使得\(x=x+k\)
- '√'按钮:使得\(x=\sqrt{x}\),此时\(x\)必须是平方数,游戏等级加1,即\(k=k+1\),且\(\sqrt{x}\)是\(k+1\)的倍数。
- 游戏开始时,\(x=2,k=1\),输出\(n(n \le 10^5)\)个数,表示每个等级对应的\(\frac{x}{k}\)值(就是倍数),并且输出的值不超过\(10^{18}\)。
任意时刻,\(x\)必须是\(k\)的倍数。
Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k.
思路
- 设\[x=kp=(k+1)^2q^2\]
- 则\[p=\frac{(k+1)^2q^2}{k}\]
如果令\(q=k\),得\[p=k(k+1)^2\]
这样的倍数显然满足题意。
代码
D. Complete The Graph
题意
- 一张图有\(n(n \le 10^3)\)个点,\(m(m \le 10^4)\)条边。
- 每条边有权值(均为正整数),当边权为0时,表示需要重新赋值,使得\(s \to t\)的最短路径长为\(L(L \le 10^9)\)。
- 若存在一种方案,输出"YES"和所有边的边权;否则输出"NO"。
思路
- 是否存在可以通过极端情况判断,即将所有0边赋值为1以及全赋值为L。
- 若存在,显然可以二分出权值\(x\),使得所有0边均赋值为\(x\)时,\(s \to t\)的最短路刚好大于或等于\(L\)。
- 此时我们可以通过将某些边从\(x\)变成\(x-1\)使得最短路变成\(L\),这样的时间复杂度为\(O(NM\log{N})\),是可以解决的。
- 题解提到了一种复杂度更优的做法,大概思想是二分找到第一条0边,使得最短路小于\(L\),找到后再二分该边的权值,使得最短路刚好为\(L\)。
代码
E. Digit Tree
题意
- 给一棵树,有\(n(n \le 10^5)\)个点。
- 边有权值\(w_i(1 \le w_i \le 9)\)。
- 求路径\((u,v)\)使得\(u \to v\)路径构成的大数模\(m\)为0,其中\(gcd(10, m) = 1\)。
思路
- 点分治
- 根据欧拉定理\[x^{\phi{(m)}}\equiv 1(mod \verb' 'm), gcd(x, m)=1\]可以求出10的逆元。
代码
Codeforces Round #372 (Div. 2)的更多相关文章
- Codeforces Round #372 (Div. 2) A .Crazy Computer/B. Complete the Word
Codeforces Round #372 (Div. 2) 不知不觉自己怎么变的这么水了,几百年前做A.B的水平,现在依旧停留在A.B水平.甚至B题还不会做.难道是带着一种功利性的态度患得患失?总共 ...
- Codeforces 715B & 716D Complete The Graph 【最短路】 (Codeforces Round #372 (Div. 2))
B. Complete The Graph time limit per test 4 seconds memory limit per test 256 megabytes input standa ...
- Codeforces 715A & 716C Plus and Square Root【数学规律】 (Codeforces Round #372 (Div. 2))
C. Plus and Square Root time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- Codeforces 716A Crazy Computer 【模拟】 (Codeforces Round #372 (Div. 2))
A. Crazy Computer time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- Codeforces 716B Complete the Word【模拟】 (Codeforces Round #372 (Div. 2))
B. Complete the Word time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- Codeforces Round #372 (Div. 2) C 数学
http://codeforces.com/contest/716/problem/C 题目大意:感觉这道题还是好懂得吧. 思路:不断的通过列式子的出来了.首先我们定义level=i, uplevel ...
- Codeforces Round #372 (Div. 1) A. Plus and Square Root 数学题
A. Plus and Square Root 题目连接: http://codeforces.com/contest/715/problem/A Description ZS the Coder i ...
- Codeforces Round #372 (Div. 2) C. Plus and Square Root
题目链接 分析:这题都过了2000了,应该很简单..写这篇只是为了凑篇数= = 假设在第级的时候开方过后的数为,是第级的系数.那么 - 显然,最小的情况应该就是, 化简一下公式,在的情况下应该是,注意 ...
- Codeforces Round #372 (Div. 2) C
Description ZS the Coder is playing a game. There is a number displayed on the screen and there are ...
随机推荐
- IT公司100题-15-求二元查找树的镜像
问题描述: 输入一颗二元查找树,将该树转换为它的镜像树,即对每一个节点,互换左右子树. 例如输入: 6/ \4 12/ \ / \2 5 8 16 输出: 6/ ...
- 基于K2 BPM平台,中原地产实现了从2个人到5万多人的跨越
演讲人:吴付文 中原地产CIO 点击这里查看中原地产怎么使用BPM实现业绩的飞跃式发展.
- linux下一键安装 powershell,的bash脚本
说明 目前,linux下的powershell约等于pash.希望大家专注mono,关注pash. 一键安装脚本包括for centos6,centos7,ubuntu 14.04 ubuntu 1 ...
- 多功能节点连线绘图控件Nevron Diagram for .NET使用方法及下载地址
Nevron Diagram for .NET是一个功能强大,世界上顶级的.NET图表控件.可扩展的图形报表构架,可以帮您创建功能丰富的Winforms及Webforms图表解决方案.这个产品构建于N ...
- Android 应用按两下返回键退出应用程序
在android应用开发中,有时候应用会用到按两下返回键退出应用的功能,今天介绍一下这个功能,直接上代码: @Override public boolean dispatchKeyEvent(KeyE ...
- [Java]Java简介
Java版本历史 1995年5月23日,Java语言诞生 1996年1月,第一个JDK1.0诞生 1996年4月,10个最主要的操作系统供应商申明将在其产品中嵌入JAVA技术 1996年9月,约8.3 ...
- Hadoop 重启各个节点
对于datanode可以在master中配置,然后在maste启动的时候,一并去启动这些节点 .对于死掉的节点,也可以通过以下命令启动 .重启挂掉的节点进入到 挂掉的机器 bin/hadoop-dae ...
- SharePoint 2010 BCS - 概述
博客地址 http://blog.csdn.net/foxdave SharePoint 2010首次引入了BCS的概念 - Business Connectivity Service,即业务连接服务 ...
- iOS 中 #import同@class之间的区别
很多刚开始学习iOS开发的同学可能在看别人的代码的时候会发现有部分#import操作写在m文件中,而h文件仅仅使用@class进行声明,不禁纳闷起来,为什么不直接把#import放到h文件中呢? 这是 ...
- Oracle 中批量导入大量测试数据的方法
执行如下批处理命令: declare maxrecords constant int := 100000; i int := 1;begin for i in 1 .. 20000 loop ...