2705: [SDOI2012]Longge的问题

Time Limit: 3 Sec  Memory Limit: 128 MB
Submit: 930  Solved: 601
[Submit][Status]

Description

Longge的数学成绩非常好,并且他非常乐于挑战高难度的数学问题。现在问题来了:给定一个整数N,你需要求出∑gcd(i, N)(1<=i <=N)。

Input

一个整数,为N。

Output

一个整数,为所求的答案。

Sample Input

6

Sample Output

15

HINT

【数据范围】

对于60%的数据,0<N<=2^16。

对于100%的数据,0<N<=2^32。

题解:

代码:

 var i:longint;
n,k,ans:int64;
procedure main;
begin
readln(n);
ans:=n;
for i:= to trunc(sqrt(n)) do
if n mod i= then
begin
k:=;
while n mod i= do
begin
inc(k);
n:=n div i;
end;
inc(ans,ans*(i-)*k div i);
end;
if n<> then inc(ans,ans*(n-)* div n);
writeln(ans);
end;
begin
main;
end.

SDOI2012Longge的问题的更多相关文章

  1. bzoj题目分类

    转载于http://blog.csdn.net/creationaugust/article/details/513876231000:A+B 1001:平面图最小割,转对偶图最短路 1002:矩阵树 ...

随机推荐

  1. CentOS安装配置Git服务器(gitosis)

    主要参考: http://blog.csdn.net/dengjianqiang2011/article/details/9260435 辅助参考: http://freeloda.blog.51ct ...

  2. nodejs read/write file

    fs.readFile('c:\\tmp\\helloworld.txt','utf8',function(err,data){console.log(data);}) var token=fs.re ...

  3. poj 2728 Desert King (最小比例生成树)

    http://poj.org/problem?id=2728 Desert King Time Limit: 3000MS   Memory Limit: 65536K Total Submissio ...

  4. centos7安装mplayer以及出现的各种问题

    首先,centos7默认的视频播放器基本不能用,这里我们选择mplayer作为视频播放器. 安装的过程,痛并快乐着....... 首先我们去mplayer的官网下载需要的文件,http://www.m ...

  5. WPF MultiDataTrigger

    huhu <Style x:Key="Cell" TargetType="{x:Type Button}"> <Setter Property ...

  6. 谈谈js中for in 需要注意的地方

    js中for in 可以遍历对象或数组的显性属性,也就是说我们自己定义的属性是可以遍历的,那些原型上默认已有的属性,例如:Object.prototype.toString.Object.protot ...

  7. php站点

    thinkphp wordpress 记事狗 phpcms http://jingyan.baidu.com/article/4b07be3c61e93e48b380f3fd.html

  8. define中的:#,##,#@

    [define中的:#,##,#@] #define Conn(x,y) x##y #define ToChar(x) #@x #define ToString(x) #x (2)x##y表示什么?表 ...

  9. SQL Server CONVERT() 函数

    http://www.w3school.com.cn/sql/func_convert.asp 定义和用法 CONVERT() 函数是把日期转换为新数据类型的通用函数. CONVERT() 函数可以用 ...

  10. hdu 4557 非诚勿扰

    水题…… 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include<io ...