SPOJ DIVSUM Divisor Summation
来源:互联网 发布:vmware linux nat模式 编辑:程序博客网 时间:2024/06/15 03:43
DIVSUM - Divisor Summation
Given a natural number n (1 <= n <= 500000), please output 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 (equal to about 200000), and that many lines follow, each containing one integer between 1 and 500000 inclusive.
Output
One integer each line: the divisor summation of the integer given respectively.
Example
Sample Input:321020Sample Output:1822
Warning: large Input/Output data, be careful with certain languages
打表
#include <cstdio>using namespace std;int t, n;int sum[500100];int main(){ scanf("%d", &t); for (int i = 1; i <= 500000; i++){ for (int j = 2; i * j <= 500000; j++){ sum[i * j] += i; } } while (t--){ scanf("%d", &n); printf("%d\n", sum[n]); } return 0;}
0 0
- SPOJ DIVSUM Divisor Summation
- SPOJ DIVSUM Divisor Summation
- spoj DIVSUM
- Divisor Summation
- SPOJ 74. Divisor Summation 分解数字的因子
- zoj 2095.Divisor Summation
- ZOJ 2095 Divisor Summation
- Divisor Summation约数之和
- F-Divisor Summation|约数枚举
- SPOJ 1029 Matrix Summation
- ZOJ Problem Set - 2095 Divisor Summation
- ZOJ 2095 Divisor Summation (求因子和)
- UVALive-7225 Summation and Divisor【Gcd+思维】
- 数论中的基本算法 POJ 1845 SPOJ DIVSUM
- Solution of ZOJ 2095 Divisor Summation (Online Version)
- Divisor Summation(与求约数个数类似)
- spoj 1029. Matrix Summation(二维树状数组)
- 统计矩阵和 二维树状数组 SPOJ 1029 Matrix Summation
- Codeforces 584B Kolya and Tanya 【组合数学】
- nginx学习之自旋锁nginx_spinlock
- hdu1078 记忆化搜索
- CCF 日期计算
- APNS推送服务证书制作 图文详解教程
- SPOJ DIVSUM Divisor Summation
- GraphLab Create API 中文文档 - 数据工程
- Python 学习笔记 装饰器 与 context
- InvalidDataAccessApiUsageException 和 Write operations are not allowed in read-only mode 解决方法
- 杨辉三角
- AllJoyn+Android开发的一般步骤
- HDU 1686
- HDU-1437(天气情况)
- 【Usaco 2008 Oct】灌水