zoj 2095 Divisor Summation
和 hdu 1215 一个意思
// 只是我 1坑了 1 时应该为0
#include <iostream>
#include <math.h>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <string.h>
using namespace std;
#define maxm 10010
#define maxn 1000010
int prim[maxn/],p;
bool f[maxn];
int gcd(int a,int b){
int r;
while(r=a%b){a=b;b=r;}
return b;
}
bool isp(int n){
if(n==) return true;
if(n%==||n==) return false;
int m=(int)(sqrt(n+1.0));
for(int i=;i<=m;i+=)
if(n%i==) return false;
return true;
}
int getprime(){
int i,j;
f[]=true;
for(i=;i<=maxn;i+=)
f[i]=true;
int m=(int)(sqrt(maxn+1.0));
for(i=;i<=m;i+=){
for(j=i*i;j<=maxn;j+=i)
f[j]=true;
}
for(i=;i<=maxn;i++)
if(!f[i]) prim[p++]=i;
}
int sum[maxn];
void sum_divisor(int n){
int i,j;
for(i=;i<=n/;i++)
for(j=i+i;j<=n;j+=i)
sum[j]+=i;
}
int main()
{
int n;
int m;
int i,k;
sum_divisor(maxn/);
sum[]=-;// 注意呀
while(scanf("%d",&n)!=EOF){
while(n--){
scanf("%d",&m);
printf("%d\n",sum[m]+);
}
} return ;
}
zoj 2095 Divisor Summation的更多相关文章
- SPOJ DIVSUM - Divisor Summation
DIVSUM - Divisor Summation #number-theory Given a natural number n (1 <= n <= 500000), please ...
- SPOJ 74. Divisor Summation 分解数字的因子
本题有两个难点: 1 大量的数据输入.没处理好就超时 - 这里使用buffer解决 2 因子分解的算法 a)暴力法超时 b)使用sieve(筛子),只是当中的算法逻辑也挺不easy搞对的. 数值N因子 ...
- ZOJ 1007 Numerical Summation of a Series
原题链接 题目大意:x的取值从0.000到2.000,输出每个x对应的y(x)的值 解法:参考了这篇日志http://www.cnblogs.com/godhand/archive/2010/04/2 ...
- Divisor Summation_
Divisor Summation Problem Description Give a natural number n (1 <= n <= 500000), please tell ...
- ZOJ 1007:Numerical Summation of a Series(数学)
Numerical Summation of a Series Time Limit: 10 Seconds Memory Limit: 32768 KB Special Judg ...
- ZOJ题目分类
ZOJ题目分类初学者题: 1001 1037 1048 1049 1051 1067 1115 1151 1201 1205 1216 1240 1241 1242 1251 1292 1331 13 ...
- ZOJ 3872 浙江2015年省赛试题
D - Beauty of Array Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu S ...
- zoj 3872
D - Beauty of Array Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu S ...
- ZOJ People Counting
第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ 3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...
随机推荐
- [设计模式] 10 外观模式 facade
外观模式应该是用的很多的一种模式,特别是当一个系统很复杂时,系统提供给客户的是一个简单的对外接口,而把里面复杂的结构都封装了起来.客户只需使用这些简单接口就能使用这个系统,而不需要关注内部复杂的结构. ...
- Oracle RAC 常用维护工具和命令
Oracle RAC 常用维护工具和命令 分类: Oracle Basic Knowledge Oracle RAC2010-03-09 01:02 13987人阅读 评论(6) 收藏 举报 orac ...
- [shell编程]一个简单的脚本
首先,为什么要学习shell呢?哈哈,当然不是shell能够怎样怎样然后100字. 最近看到一篇博文<开阔自己的视野,勇敢的接触新知识>,读完反思良久.常常感慨自己所会不多,对新知识又有畏 ...
- JsRender系列demo(7)compline
<!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery.j ...
- ***常见复杂SQL语句(含统计类SQL)
1.SQL统计某字段的出现次数 比如统计某个表中,姓名出现的次数:select name,count(*) from biao group by name having count(*) > 2 ...
- Project Euler 92:Square digit chains 平方数字链
题目 Square digit chains A number chain is created by continuously adding the square of the digits in ...
- Unity UGUI —— 无限循环List(转载)
using UnityEngine; using System.Collections; using System.Collections.Generic; using UnityEngine.UI; ...
- Tomcat处理HTTP请求源码分析(上)(转)
转载自:http://www.infoq.com/cn/articles/zh-tomcat-http-request-1 很多开源应用服务器都是集成tomcat作为web container的,而且 ...
- C++:类模板与模板类
6.3 类模板和模板类 所谓类模板,实际上是建立一个通用类,其数据成员.成员函数的返回值类型和形参类型不具体指定,用一个虚拟的类型来代表.使用类模板定义对象时,系统会实参的类型来取代类模板中虚拟类型从 ...
- 示例:Servlet读取文件内容并在页面打印输出
package com.mhb; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; impo ...