Codeforces Round #372 (Div. 2)

C. Plus and Square Root

题意

  • 一个游戏中,有一个数字\(x\),当前游戏等级为\(k\),有两种操作:
  1. '+'按钮:使得\(x=x+k\)
  2. '√'按钮:使得\(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)的更多相关文章

  1. Codeforces Round #372 (Div. 2) A .Crazy Computer/B. Complete the Word

    Codeforces Round #372 (Div. 2) 不知不觉自己怎么变的这么水了,几百年前做A.B的水平,现在依旧停留在A.B水平.甚至B题还不会做.难道是带着一种功利性的态度患得患失?总共 ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. Codeforces Round #372 (Div. 2) C 数学

    http://codeforces.com/contest/716/problem/C 题目大意:感觉这道题还是好懂得吧. 思路:不断的通过列式子的出来了.首先我们定义level=i, uplevel ...

  7. 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 ...

  8. Codeforces Round #372 (Div. 2) C. Plus and Square Root

    题目链接 分析:这题都过了2000了,应该很简单..写这篇只是为了凑篇数= = 假设在第级的时候开方过后的数为,是第级的系数.那么 - 显然,最小的情况应该就是, 化简一下公式,在的情况下应该是,注意 ...

  9. 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 ...

随机推荐

  1. 标准库源码--wsgi服务器

    功能模块化带来可自由组装的便利: 使用python的mixin特性装配 class ThreadHTTPServer(ThreadingMixin, HTTPServer): pass 上面表示1个请 ...

  2. linux下的powershell,pash试用手记

    ------1 概述------ 1.1 简单来说linux,unix是非常依赖脚本的,而win不是.win中有很多图形程序+c库,效率不比脚本差.点几下鼠标照样能完成需求.当 然,图形和字符是两码事 ...

  3. CentOS 6.4 U盘启动问题的解决

    替换syslinux/目录下的vesamenu.c32文件. 下载地址: http://pan.baidu.com/s/1mg8xce8

  4. UIScrollerView常见属性

    CGSize contentSize :设置UIScrollView的滚动范围 CGPoint contentOffset :UIScrollView当前滚动的位置 UIEdgeInsets cont ...

  5. ios开发值json数据文件的存取

    将Json存进本地文件夹   NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainM ...

  6. droidbox官网

    droidbox官网,droidbox已经移植到github上了 https://github.com/pjlantz/droidbox

  7. Interview----判断两个链表是否相交?

    题目描述: 判断两个单链表是否相交?假设链表没有环. 假如链表有环呢? 1.  假如没有环 那么如果两个链表相交的话,必然最后的节点一定是同一个节点.所以只需要各自扫描一遍链表,找到最后一个节点,比较 ...

  8. grunt 执行

    几天以前,我决定开始启用一个CSS预处理器,找了很久,我选择了SASS并且尝试着去安装它.但是这似乎不是一件简单的事,在安装过程中出现了许多让我始料不及的问题,我很沮丧,但查找了很多资料,我终于找到了 ...

  9. 【转】高性能Javascript--脚本的无阻塞加载策略

    原文转自:http://blog.jobbole.com/78191/ Javascript在浏览器中的性能,可以说是前端开发者所要面对的最重要的可用性问题. 在Yahoo的Yslow23条规则当中, ...

  10. ng-init