题目链接:hdu 4342 History repeat itself 题意: 让你找第a个非完全平方数m,并且求前m个数的开方向下取整的和. 题解: 第一个问题: 假设第a个非平方数是X,X前面有n个平方数,则n*n<X<(n+1)*(n+1); n*n前面的非平方数的个数是n*n-n; 首先先根据a求n,n是满足不等式  n*n-n<a的最大正整数. 不等式的解是: (1+sqrt(1+4*a))/2;必需对这个数上取整,然后减一就是n了. 然后第a个非平方数就是  n*n+(a-n…
History repeat itself Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. Original ID: 434264-bit integer IO format: %I64d      Java class name: Main Prev Submit Status Statistics Discuss Next Type: None   None Graph Theory 2…
题目传送门 题意:计算从1开始到第n个非完全平方数的开方和 分析:设第n个非完全平方数的值为a,x * x < a < (x+1) * (x+1),而且易得(tmp = sqrt (a) ) == x,a之前的非完全平方数的个数为a - tmp,所以可以二分查找a - tmp == n的a,然后模拟一下能计算出前a个数的开方和 收获:二分查找是个好方法 代码: /************************************************ * Author :Running…
C - History repeat itself Time Limit:1000MS     Memory Limit:32768KB      Description Tom took the Discrete Mathematics course in the 2011,but his bad attendance angered Professor Lee who is in charge of the course. Therefore, Professor Lee decided t…
History repeat itself Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4342 Description Tom took the Discrete Mathematics course in the 2011,but his bad attendance angered Professor Lee who is in…
BUPT2017 wintertraining(15) #8C 题意 求第n(n<2^32)个非完全平方数m,以及\(\sum_{i=1}^m{\lfloor\sqrt i\rfloor}\) 题解 设1~m中有x个完全平方数(\(1^2,2^2,3^2,...,x^2\)). 那么有 \[ \begin{cases} n+x=m\\ x^2 < m\\ (x+1)^2 \ge m \end{cases} \] 等价于求满足\(m-\sqrt m < n\)的m的最大值. 于是可以二分.…
Pokémon GO Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 171    Accepted Submission(s): 104 Problem Description 众所周知,度度熊最近沉迷于 Pokémon GO. 今天它决定要抓住所有的精灵球! 为了不让度度熊失望,精灵球已经被事先放置在一个2*N的格子上,每一个格子上都…
Balls and Boxes 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5810 Description Mr. Chopsticks is interested in random phenomena, and he conducts an experiment to study randomness. In the experiment, he throws n balls into m boxes in such a manner t…
WisKey的眼神 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2059    Accepted Submission(s): 625 Problem Description WisKey的眼镜有500多度,所以眼神不大好,而且他有个习惯,就是走路喜欢看着地(不是为了拣钱哦^_^),所以大家下次碰见他的时候最好主动打下招呼,呵呵.但是…
这道题比赛中没做出来,赛后搞了好久才出来的,严重暴露的我薄弱的数学功底, 这道题要推公式的,,,有类似于1*a+2*a^2+3*a^3+...+n*a^n的数列求和. 最后画了一张纸才把最后的结果推出来.::(x*M^x)/N. 而且通过这道题我发现有些数学函数还不如直接循环来的快, 例如这道题中求x的值的时候. [我在此收回前面的话,昨天是oj的问题,今天我又交了一遍log的代码,耗时变成了0ms了...OMG] 方法一: int x = int(log(n)/log(m)+0.5);    …