思路:

找规律。

实现:

 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll n;
while (cin >> n)
{
ll cnt = ;
for (int i = ; i * i <= n; i++)
{
ll tmp = n / i;
cnt += (i + + tmp) * (tmp - i) / ;
cnt += (tmp - i + ) * i;
}
cout << (cnt << ) << endl;
}
return ;
}

CF1062D Fun with Integers的更多相关文章

  1. [LeetCode] Sum of Two Integers 两数之和

    Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Exam ...

  2. [LeetCode] Divide Two Integers 两数相除

    Divide two integers without using multiplication, division and mod operator. If it is overflow, retu ...

  3. HDU 1796How many integers can you find(容斥原理)

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

  4. Leetcode Divide Two Integers

    Divide two integers without using multiplication, division and mod operator. 不用乘.除.求余操作,返回两整数相除的结果,结 ...

  5. LeetCode Sum of Two Integers

    原题链接在这里:https://leetcode.com/problems/sum-of-two-integers/ 题目: Calculate the sum of two integers a a ...

  6. Nim Game,Reverse String,Sum of Two Integers

    下面是今天写的几道题: 292. Nim Game You are playing the following Nim Game with your friend: There is a heap o ...

  7. POJ 3468 A Simple Problem with Integers(线段树 成段增减+区间求和)

    A Simple Problem with Integers [题目链接]A Simple Problem with Integers [题目类型]线段树 成段增减+区间求和 &题解: 线段树 ...

  8. LeetCode 371. Sum of Two Integers

    Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Exam ...

  9. leetcode-【中等题】Divide Two Integers

    题目 Divide two integers without using multiplication, division and mod operator. If it is overflow, r ...

随机推荐

  1. VirtualBox下安装ubuntu图文教程以及软件安装

    一. 下载安装VirtualBox 官网下载VirtualBox,目前版本:VirtualBox 5.1.8 for Windows hosts x86/amd64 下载好了安装VirtualBox, ...

  2. c++ zlib(qt)压缩与解压缩

    #include <QtCore/QCoreApplication> #include "zlib.h" #include "stdio.h" #i ...

  3. Ubuntu18.04 安装 JDK7

    直接下载jdk压缩包方式安装 1.官网下载JDK      地址: http://www.oracle.com/technetwork/articles/javase/index-jsp-138363 ...

  4. ftp主要流程

    判断是否是root用户,若不是则提示并退出. 建立server socket. 等待用户连接,并建立相应用户的子进程.

  5. 将java项目打包成jar包,之后在制作成可执行的exe文件

    1.利用eclipse选择 2.利用ex4j,详情见百度教程http://jingyan.baidu.com/article/00a07f38aad55182d128dc4c.html

  6. mysql :库操作

    一 系统数据库 information_schema:虚拟库,不占用磁盘空间,存储的是数据库启动后的一些参数,如用户表信息,列信息, 权限信息, 字符信息等. performance_schema:M ...

  7. ZOJ3175【公式化函数的思想】

    题意:  给出f(n,m)(m<n)的定义:大于m并且小于n的能整除m的数的个数. F(n)为m从1至n的f(n,m)的和. 给出n,求F(n). 思路: 就是计算n/1 +  n/2 + n/ ...

  8. lightoj1062【几何(二分)】

    其实就应该想到,哪有那么简单让你直接搞出答案的几何题啊:(而且很有可能是二分? 题意: 有两个梯子,一个靠在左边墙上,一个靠在右边墙上,长度分别为 x 和 y,他们的交点距离地面高度是 c,求两个梯子 ...

  9. lightoj 1088【树状数组+离散化】

    题意: 给你n个数,然后给你q个区间,然后问你这n个数有多少个在这个区间上: 思路: 树状数组搞搞,但是注意到数的范围很大,所以先离散化一下. 初始化初始化!!!卧槽,wa的我好郁闷... #incl ...

  10. LightOJ 1029 【最小生成树】

    思路: 利用克鲁斯卡尔算法,最小生成树把边从小到大排序,然后Union: 最大生成树就是把边从大到小排序,然后Union: #include<bits/stdc++.h> using na ...