Description F(n) = (n % 1) + (n % 2) + (n % 3) + ...... (n % n).其中%表示Mod,也就是余数.例如F(6) = 6 % 1 + 6 % 2 + 6 % 3 + 6 % 4 + 6 % 5 + 6 % 6 = 0 + 0 + 0 + 2 + 1 + 0 = 3.给出n,计算F(n). Input 输入1个数N(2 <= N <= 10^12). Output 输出F(n). Sample Input 6 Sample Output…
http://acm.hdu.edu.cn/showproblem.php?pid=5668 这题的话,假设每次报x个,那么可以模拟一遍, 假设第i个出局的是a[i],那么从第i-1个出局的人后,重新报数到他假设经过了p个人, 那么自然x = k(n-i)+p(0<= i < n) 即x = p (mod n-i) 然后显然可以得到n个这样的方程,于是就是中国剩余定理了. 代码: #include <iostream> #include <cstdio> #includ…
http://acm.hdu.edu.cn/showproblem.php?pid=5667 这题的关键是处理指数,因为最后结果是a^t这种的,主要是如何计算t. 发现t是一个递推式,t(n) = c*t(n-1)+t(n-2)+b.这样的话就可以使用矩阵快速幂进行计算了. 设列矩阵[t(n), t(n-1), 1],它可以由[t(n-1), t(n-2), 1]乘上一个3*3的矩阵得到这个矩阵为:{[c, 1, b], [1, 0, 0], [0, 0, 1]},这样指数部分就可以矩阵快速幂了…
http://acm.hdu.edu.cn/showproblem.php?pid=5666 这题的关键是q为质数,不妨设线段上点(x0, y0),则x0+y0=q. 那么直线方程则为y = y0/x0x,如果存在点(x1, y1)在此直线上, 那么y1 = y0*x1/x0,而y0 = q-x0, 于是y1 = (q-x0)*x1/x0 = q*x1/x0-x1, 因为x0 < q,于是(x0, q) = 1, 于是x0 | x1, 而x1 < x0,于是x1 = x0, 也就是说三角形内部…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5585 题目大意就是求大数是否能被2,3,5整除. 我直接上了Java大数,不过可以对末尾来判断2和5,对所有位的和来判断3. 代码就不粘了.…
题目链接:http://codeforces.com/problemset/problem/590/A 题目大意是给两种操作,然后给你一个s,一个t,求s至少需要多少次操作到t. 考虑到第一种操作是将某一位取反,而第二种操作是抑或一个数. 显然第一种操作也是可以通过抑或一个数得到的.比如:第i位取反,相当于抑或(1<<i)这个数.于是就将n个数扩大到n+17就可以了,因为100000最多17位. 此外如果p^a^b^c...=q的话,那么a^b^c...=p^q.于是,只需要求出p^q至少需要…
Description Friend number are defined recursively as follows. (1) numbers 1 and 2 are friend number; (2) if a and b are friend numbers, so is ab+a+b; (3) only the numbers defined in (1) and (2) are friend number. Now your task is to judge whether an…
1225 余数之和 题目连接: http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1225 Description F(n) = (n % 1) + (n % 2) + (n % 3) + ...... (n % n).其中%表示Mod,也就是余数. 例如F(6) = 6 % 1 + 6 % 2 + 6 % 3 + 6 % 4 + 6 % 5 + 6 % 6 = 0 + 0 + 0 + 2 + 1 + 0 = 3. 给出n…
Description It's Saturday today, what day is it after 11 + 22 + 33 + ... + NN days? Input There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case: There is only one line con…
http://219.244.176.199/JudgeOnline/problem.php?id=1239 这是这次陕西省赛的G题,题目大意是一个n*n的点阵,点坐标从(1, 1)到(n, n),每个点都有权值,然后从(x, y)引x轴的垂线,然后构成一个三角形,三个顶点分别是(0, 0),(x, 0)和(x, y).求三角形内点的权值和,包括边界,n的范围是1000,m的范围是100000,说起来也比较坑..学弟n*m的复杂度竟然水过去了,目测比赛数据比较水..不过我挂到我们OJ上给了一组随…