刚开始做的时候不懂啊,怎么做怎么Time Limit Exceeded,那个心凉啊。

Time limit: 5 Seconds   Memory limit: 32768K   
Total Submit: 4504   Accepted Submit: 862

Give a natural number n (1 <= n <= 500000), please tell the summation of all its proper divisors.

Definition: A proper divisor of a natural number is the divisor that is strictly less than the number.

e.g. number 20 has 5 proper divisors: 1, 2, 4, 5, 10, and the divisor summation is: 1 + 2 + 4 + 5 + 10 = 22.

Input

An integer stating the number of test cases, and that many lines follow each containing one integer between 1 and 500000.

Output

One integer each line: the divisor summation of the integer given respectively.

Sample Input

3
2
10
20


Sample Output

1
8
22

Author: Neal Zane


#include <stdio.h>
int main()
{int a[500001] = { 0 , 0 } ;int i , j ;for (i = 1 ;i <= 250000;i ++)for (j = 2 ;i*j <= 500000;j ++)a[i*j] += i;scanf ("%d",&i);while (i --){scanf ("%d", &j);printf ("%d\n", a[j]);}return 0 ;
}

ZOJ 2095 Divisor Summation相关推荐

  1. 【简单】Divisor Summation

    描述 Give a natural number n (1 <= n <= 500000), please tell the summation of all its proper div ...

  2. ACM入门题目(北大ACM教材)

    这个是自己经过一段时间A的题目,非抄书!然后也自己做了一个工程把它管理起来. ACM.h   这个头文件主要是一些头文件映如以及一些ACM函数的定义 #include<iostream> ...

  3. ZOJ POJ题目分类

    ZOJ题目分类 初学者题:1001 1037 1048 1049 1051 1067 1115 1151 1201 1205 1216 1240 1241 1242 1251 1292 1331 13 ...

  4. POJ ZOJ题目分类

    POJ,ZOJ题目分类(多篇整合版,分类很细致,全面) 标签: 题目分类POJ整理 2015-04-18 14:44 1672人阅读 评论(0) 收藏 举报 本文章已收录于: 分类: ACM资料(5) ...

  5. POJ,ZOJ题目分类(多篇整合版,分类很细致,全面)

    水题: 3299,2159,2739,1083,2262,1503,3006,2255,3094 初级: 一.基本算法:        (1)枚举 (1753,2965)       (2)贪心(13 ...

  6. 【ZOJ题目分类】备忘

    ZOJ 题目 分类 初学者题: 1001 1037 1048 1049 1051 1067 1115 1151 1201 1205 1216 1240 1241 1242 1251 1292 1331 ...

  7. ZOJ 2723 Semi-Prime ||ZOJ 2060 Fibonacci Again 水水水!

    两题水题: 1.如果一个数能被分解为两个素数的乘积,则称为Semi-Prime,给你一个数,让你判断是不是Semi-Prime数. 2.定义F(0) = 7, F(1) = 11, F(n) = F( ...

  8. zoj 1204 Additive equations

    ACCEPT acm作业 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=204 因为老师是在集合那里要我们做这道题.所以我很是天 ...

  9. 【Codeforces/HDU】76A Plus and xor / 2095 find your present (2)(异或)。

    http://codeforces.com/contest/76/problem/D A = X + Y B = X xor Y 异或(不进位加法):两个二进制数,对应的位置上,相同为0,不同为1 性 ...

最新文章

  1. jquery easyui的应用-2
  2. C# 可访问性不一致问题(修改成员的访问修饰符)。
  3. java-Integer的自动装箱与拆箱
  4. mysql私房菜_老男孩MySQL私房菜深入浅出精品视频第7章备份与恢复基础实践视频课程...
  5. Linux学习总结(39)——系统管理员应该知道的 20 条 Linux 命令
  6. rename批量修改文件名
  7. idea文件为橙色去掉版本控制
  8. MAVEN利用Profile构建不同环境的部署包
  9. 将多个csv文件整合到一个csv文件中
  10. vs2017配置pthread.h的方法
  11. STM32 IIC协议详解
  12. Resource is out of sync with the file system的解决办法
  13. 从输入URL到页面加载的过程?由一道题完善自己的Web前端知识体系!
  14. word页脚显示不全
  15. NET 页面生命周期
  16. Android界面开发
  17. 五种提高 SQL 性能的方法 [来源:MSDN Johnny Papa]
  18. 没有任何销售经验怎么进行销售团队管理?
  19. 见女网友遇见最尴尬的事
  20. 学习笔记---原文网址在第一行

热门文章

  1. cadence allegro导入dxf文件
  2. vue用el-select和el-tree实现树状结构单击选中
  3. FLEX绘制行政区域地图源码
  4. 名字竞技场 V3.0
  5. 权重掩码单网络多任务:Piggyback: Adapting a Single Network to Multiple Tasks by Learning to Mask Weights
  6. 山大计算机毕业生去向,985就业:山东大学的毕业生们都被哪些单位录取了?19届就业情况...
  7. BMP位图转为RGB三通道图
  8. excel表格往下拉数字不变该怎么解决?
  9. 【方法】如何使用DeepMask和SharpMask
  10. 10个实用的UX设计作品推销小窍门