CF1062D Fun with Integers
思路:
找规律。
实现:
#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的更多相关文章
- [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 ...
- [LeetCode] Divide Two Integers 两数相除
Divide two integers without using multiplication, division and mod operator. If it is overflow, retu ...
- HDU 1796How many integers can you find(容斥原理)
How many integers can you find Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d ...
- Leetcode Divide Two Integers
Divide two integers without using multiplication, division and mod operator. 不用乘.除.求余操作,返回两整数相除的结果,结 ...
- LeetCode Sum of Two Integers
原题链接在这里:https://leetcode.com/problems/sum-of-two-integers/ 题目: Calculate the sum of two integers a a ...
- 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 ...
- POJ 3468 A Simple Problem with Integers(线段树 成段增减+区间求和)
A Simple Problem with Integers [题目链接]A Simple Problem with Integers [题目类型]线段树 成段增减+区间求和 &题解: 线段树 ...
- 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 ...
- leetcode-【中等题】Divide Two Integers
题目 Divide two integers without using multiplication, division and mod operator. If it is overflow, r ...
随机推荐
- some characters cannot be mapped using iso-8859-1 character encoding
Eclipse中新建一个.properties文件,如果输入中文保存时就会提示错误 Reason:some characters cannot be mapped using "ISO-88 ...
- 转:CURL库在程序中的运用浅析
CURL库在程序中的运用浅析-nk_ysg-ChinaUnix博客 http://blog.chinaunix.net/uid-22476414-id-3286638.html 这个目录的文章转载fr ...
- Ladies' Shop
题意: 有 $n$ 个包,设计最少的物品体积(可重集),使得 1. 对于任意一个总体积不超过给定 $m$ 的物体集合有其体积和 恰好等于一个包的容量. 2.对于每一个包,存在一个物品集合能恰好装满它. ...
- 1.5 sqoop安装及基本使用
一.安装sqoop 1.解压 ##解压 [root@hadoop-senior cdh]# tar zxf sqoop-1.4.5-cdh5.3.6.tar.gz -C /opt/cdh-5.3.6/ ...
- struts2 中的 addActionError 、addFieldError、addActionMessage的方法
addActionError .addFieldError.addActionMessage都是ActionSupport的方法 一.addActionError("错误内容"): ...
- JAVA基础--JAVA API常见对象(包装类和正则)12
一.基本类型包装类 1.基本类型包装类介绍 8种基本类型: byte short int long float double char boolean 这8种基本类型它 ...
- Spring中配置Dbutils
<!--配置QueryRunner--> <bean id="runner" class="org.apache.commons.dbutils.Que ...
- Weekly Contest 78-------->809. Expressive Words (stack)
Sometimes people repeat letters to represent extra feeling, such as "hello" -> "he ...
- URAL1222
题意: 把n拆分成几个数,把这些数乘起来最大. 思路: 3越多越好. 对4,5特判一下,4的时候是2*2大,5的时候还剩个2,那么就是n%3=1的话,我们先拿个4,n%3==2的话就是先拿个2,后面把 ...
- 打包时,指定war包的名称
在pom.xml中修改finalName节点的值即可,如下: <build> <plugins> <plugin> <groupId>org.sprin ...