zoukankan      html  css  js  c++  java
  • NOIP培训Day9 [1]约数研究

    约数研究

    (num.pas/c/cpp)

    时限1s,空间256MB

    【题目背景】

    F(n)表示n的约数个数,现在给出n,要求求出f(1)到f(n)的总和。

    【输入格式】

    输入一行,一个整数n

    【输出格式】

    输出一个整数,表示总和

    【样例输入】

    3

    【样例输出】

    5

    【数据范围】

    20%:N<=5000

    100%:N<=1000000

    【题解】

    这题完全是一道水题!

    具体代码实现:(By Tony)

    /*
     * Number theory Problem  -  Sum of divisors
     * Code By TonyFang
     * Mail To tony-fang@foxmail.com
     * Copyright TonyFang (in CodeForces) 2013
     * All rights reserved.
     * Copyright TonyFang 2000-2013 (now)
     * All rights reserved.
     * num.cpp   /    input:num.in     /     output:num.out
     */
    # include <iostream>
    # include <stdio.h>
    # include <stdlib.h>
    # include <string.h>
    # include <math.h>
    # include <algorithm>
    using namespace std;
    int main() {
    	freopen("num.in","r",stdin);
    	freopen("num.out","w",stdout);
    	long long n,ans = 0;
    	cin >> n;
    	for (int i = 1;i <= n / 2;i ++)
    		ans += n / i;
    	if (n & 1) ans += n / 2 + 1;
    	else ans += n / 2;
    	cout << ans << endl;
    	return 0;
    }
    
    这篇文章由TonyFang发布。 所有解释权归TonyFang所有。 Mailto: tony-fang@map-le.net
  • 相关阅读:
    JPA的一对一映射
    JPA的查询语言—JPQL的命名查询@NamedQuery
    JPA的persistence.xml文件
    JPA的主键产生策略
    JPA的查询语言—JPQL的简单查询
    Oracle Flashback救急了一回
    JPA的实体
    JPA的一对多映射(双向)
    JPA的一对多映射(单向)
    MySQL 主从同步操作文档
  • 原文地址:https://www.cnblogs.com/TonyNeal/p/sdfzday9_1.html
Copyright © 2011-2022 走看看