hdu 4944 FSF’s game(数论)】的更多相关文章

题目链接:hdu 4944 FSF's game 题目大意:给定N,能够用不大于N的长a和宽b.组成N∗(N−1)2种不同的矩形,对于每一个矩形a∗b要计算它的值,K为矩形a,b能够拆分成若干个K∗K的正方形.∑a∗bgcd(a/k,b/k),输出全部矩形值的和. 解题思路:如果有边a和b.那么k肯定即使a的因子也是b的因子. 定义f(n)为矩形最长边等于n的情况下全部矩形值的和.那么f(n)=val(1∗n)+val(2∗n)+⋯+val(n∗n),枚举n的因子作为k,如今如果有因子k,使得n…
FSF’s game Time Limit: 9000/4500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 727    Accepted Submission(s): 377 Problem Description FSF has programmed a game.In this game, players need to divide a rectangle int…
Problem Description FSF has programmed a game. In this game, players need to divide a rectangle into several same squares. The length and width of rectangles are integer, and of course the side length of squares are integer. After division, players c…
思路:  ans[n]=  ans[n-1] + { (n,1),(n,2).....(n,n)}  现在任务 是 计算  { (n,1),(n,2).....(n,n)}(k=n的任意因子) 很明显  所有能取的k均为n的因子可以 sqrt(n) 内枚举.  若 p 为n的因子   那么  d(n,p) =p*p  *     {(n/p,1) ,(n/p,2) ...(n/p,n/p)}(后面这部分 k 取 1) 那么任务就转化成求   f(n)     f(n)表示 {(n,1),(n,2…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2114 自己对数论一窍不通啊现在,做了一道水题,贴出来吧...主要是让自己记住这个公式: 前n项和的立方公式为   : s(n)=(n*(n+1)/2)^2; 前n项和的平方公式为:s(n)=n*(n+1)(2*n+1)/6; 代码: #include<iostream> #include<cstdlib> #include<cstdio> using namespace s…
Diophantus of Alexandria Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2269    Accepted Submission(s): 851 Problem Description Diophantus of Alexandria was an egypt mathematician living in Ale…
Sqrt Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5752 Description Let's define the function f(n)=⌊n−−√⌋. Bo wanted to know the minimum number y which satisfies fy(n)=1. note:f1(n)=f(n),fy(n)=f(fy−1(n)) It is a pity that Bo can only use 1 unit…
Couple doubi 题目链接: http://acm.hust.edu.cn/vjudge/contest/121334#problem/D Description DouBiXp has a girlfriend named DouBiNan.One day they felt very boring and decided to play some games. The rule of this game is as following. There are k balls on th…
题意:三个数x, y, z. 给出最大公倍数g和最小公约数l.求满足条件的x,y,z有多少组. 题解:设n=g/l n=p1^n1*p2^n2...pn^nk (分解质因数 那么x = p1^x1 * p2^x2 * .... ^ pn^xk y = p1^y1 * p2^y2 * .... ^ pn^yk x = p1^z1 * p2^z2 * .... ^ pn^zk 那么对于任意i (0<=i<=k) 都有 min(xi, yi, zi) = 0, max(xi, yi, zi) = n…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1060   这道题运用的是数学方法. 假设S=n^n.两边同时取对数,得到lgS=nlgn.即有S=10^(nlgn). 把nlgn看做一个整体,假设它是由整数加上介于0到1之间的小数相加得到的. 那么整数部分就不考虑了,就单纯的放大倍数而已.取决于小数部分. 小数部分=nlgn-(__int64)nlgn.注意是__int64.因为小数部分在0到1之间,所以10得次方得到的数必定大于等于1且小于10…