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. git命令行

    cmd下运行或者 进入git bash运行 输入 exit退出切换到仓库目录后再git statusgit commit -m 注释 git pull origin1 mastergit push o ...

  2. butterknife7.0.1使用

    1.官网:http://jakewharton.github.io/butterknife/ Introduction Annotate fields with @Bind and a view ID ...

  3. 查看某一个点是否在某个多边形内 使用ST_Contains函数

    查看某一个点是否在某个多边形内  使用ST_Contains函数 --LINESTRING ( 121.312350 30.971457 , 121.156783 31.092221 , 121.35 ...

  4. sharepoint One-Time Passwords (windows basic authentication)

    //设计中,未完成 references: http://www.asp.net/web-api/overview/security/basic-authentication http://techn ...

  5. uxpin books

    http://uxpin.com/knowledge.html/?utm_source=Email+Marketing+Automation&utm_campaign=80d94e146a-l ...

  6. Jquery实现自动提示下拉框

    1.引入脚本库:     <script type="text/javascript" src="/Jscripts/jquery-1.3.2.js"&g ...

  7. CentOS6.4 安装 mongo-connector

    mongo-connector在python2.6.6版本下安装不成功,官方测试2.7,3.3正常 需要升级python2.7 具体步骤: 安装开发工具包: yum groupinstall &quo ...

  8. 免费素材:25套免费的 Web UI 设计的界面元素(转)

    Web 元素是任何网站相关项目都需要的,质量和良好设计的元素对于设计师来说就像宝贝一样.如果您正在为您的网站,博客,Web 应用程序或移动应用程序寻找完美设计的网页元素,那么下面这个列表会是你需要的. ...

  9. uva 10739

    dp 只有三个操作  当str[i] != str[j] 时 dp(i, j) = min(dp(i+1, j), dp(i+1, j-1), dp(i, j-1)) #include <ios ...

  10. 【leetcode】Longest Common Prefix (easy)

    Write a function to find the longest common prefix string amongst an array of strings. 思路:找最长公共前缀 常规 ...