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. 数据结构-Hash表

    实现: #ifndef SEPARATE_CHAINING_H #define SEPARATE_CHAINING_H #include <vector> #include <lis ...

  2. Spring学习笔记之Bean的实例化

    一.bean的实例化方法有3种, 1.构造器实例化 2.静态工厂方法实例化 3.实例工厂方法实例化 二.用构造器来实例化 <bean id="ShunDao" class=& ...

  3. English idioms

    a hot potato : speak of an issue(mostly current) which many people are talking about and which is us ...

  4. unix shell-01 file

    1 一个文件有三种访问方式: 1.读,可以显示该文件的内容 2.写,删除或者编辑这个文件 3.执行,如果该文件时一个shell脚本或程序 按照文件所针对的用户,用户可以分为三种: 1.文件属主,即该文 ...

  5. Dom操作html详细

    <p name='pn'>xxx</p> <p name='pn'>xxx</p> <p name='pn'>xxx</p> & ...

  6. 关押罪犯(noip2010)

    解法: (1)搜索(30分) (2)二分(此题属于最大值最小问题) (3)贪心+并查集 下面着重说一下“贪心+并查集” 因为有A.B两座监狱,每个犯人不是在A,就是在B监狱. 至于每个犯人在那个监狱, ...

  7. JS 数组去重!!!

    var arr = [1,2,3,1,1,1,3,5,3,6,2]; var newArr=[]; for(var i = 0; i < arr.length-1; i++){ var onOf ...

  8. c规范(2)

    一:对齐 1 程序的分界符' {'和' }'应独占一行并且位于同一列,同时与引用它们的语句左对齐. 2  { }之内的代码块在' {'右边数格处左对齐. 二:注释 注释通常用于:( 1)版本.版权声明 ...

  9. mysql 批量创建表,利用存储过程

    最近根据需求,需要提前创建一批日志表,以日期结尾,每天创建一张,例如XXX20160530,请参考如下: BEGIN    DECLARE `sName` VARCHAR(128);   DECLAR ...

  10. 技术分享:如何用Solr搭建大数据查询平台

    0×00 开头照例扯淡 自从各种脱裤门事件开始层出不穷,在下就学乖了,各个地方的密码全都改成不一样的,重要帐号的密码定期更换,生怕被人社出祖宗十八代的我,甚至开始用起了假名字,我给自己起一新网名”兴才 ...