TZOJ 4651 zry和他的的灯泡们(lca)】的更多相关文章

描述 zry有一个收集灯泡的习惯,他把灯泡的阴极都共地,阳极连成一颗树,这样的话,他只要在任意一个灯泡的阳极加上合适的电压,所有灯泡都能亮起来.不幸的是,有一对灯泡之间的阳极连线断掉了,这样的话,这颗灯泡树就还有一部分能亮,一部分不能亮了.zry想知道如果他在任意一个灯泡的阳极上加电压,这一对灯泡的哪一个会亮? 输入 首先是一个正整数T(1<=T<=10)表示测试数据的组数.对于每一组测试数据:第一行是一个整数n,q(3<=n,q<=100000),n表示灯泡总数,q表示查询个数.…
There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it's off or turning off if it's on). For the nth round, you only toggle th…
描述 一个房间里有n盏灯泡,一开始都是熄着的,有1到n个时刻,每个时刻i,我们会将i的倍数的灯泡改变状态(即原本开着的现将它熄灭,原本熄灭的现将它点亮),问最后有多少盏灯泡是亮着的. 提示 范围:40%的数据保证,n<=maxlongint 100%的数据保证,n<=10^200 ********************************************************************** 1.编个小程序,打表(1-30),可以看出规律         f(n)=…
JS学习笔记1(学自W3school)        function changeImage()  {  element = document.getElementByIdx_x('myimage')  if (element.src.match("bulbon"))  {   element.src="http://www.w3school.com.cn/i/eg_bulboff.gif";  }else{ element.src="http://ww…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4651 题意:给出n.求其整数拆分的方案数. i64 f[N]; void init(){    f[0]=f[1]=1; f[2]=2;    int i,j,k,t;    for(i=3;i<N;i++) for(j=1;;j++)    {        FOR0(k,2)        {            if(!k) t=(3*j*j-j)/2;            else t=…
vijosP1447 开关灯泡 链接:https://vijos.org/p/1447 [思路] 数学+高精度. 分析题目:题中有言,i时刻将其所有倍数的灯熄灭,由此得知一个数有多少个倍数就会被操作多少次,因为初始全部熄灭,所以操作数为奇的灯最后会亮着,再进一步,只有序号为平方数的灯在最后会亮着. 由此题目转化为求n以内平方数的个数,个数为sqrt(n)个(别问我怎么知道的=_=) 数据范围要求我们用到高精.至此,题目就是对一个大数开方的问题,NOIP的初赛曾出现过这个程序. [代码] #inc…
下面内容摘自维基百科: 五边形数定理[编辑] 五边形数定理是一个由欧拉发现的数学定理,描写叙述欧拉函数展开式的特性[1] [2].欧拉函数的展开式例如以下: 亦即 欧拉函数展开后,有些次方项被消去,仅仅留下次方项为1, 2, 5, 7, 12, ...的项次,留下来的次方恰为广义五边形数. 当中符号为- - + + - - + + ..... 若将上式视为幂级数,其收敛半径为1,只是若仅仅是当作形式幂级数(formal power series)来考虑,就不会考虑其收敛半径. 和切割函数的关系…
题意:把一个整数N(1 <= N <= 100000)拆分不超过N的正整数相加,有多少种拆法. 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4651 ——>>好经典的问题,但数好大,比赛卡住了... 原来,这个问题有个公式计算: q[i]为第i个广义五边形数. #include <cstdio> using namespace std; const int maxn = 100000; const int mod = 1…
There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it's off or turning off if it's on). For the i-th round, you toggle every …
There is a room with n lights which are turned on initially and 4 buttons on the wall. After performing exactly munknown operations towards buttons, you need to return how many different kinds of status of the n lights could be. Suppose n lights are…