链接

[http://codeforces.com/contest/1062/problem/D]

题意

给你n,让你从2到n这个区间找任意两个数,使得一个数是另一个的因子,绝对值小的可以变为绝对值大的

问你这变化过程所乘的倍数绝对值之和

分析

见过最简单的D题,直接在范围内找出倍数并保存倍数

自己看样例也就知道只是正负换了

因为会重复所不乘以4而是乘以2,看代码就知道了

代码

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[1000005];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll n;
while(cin>>n){
memset(a,0,sizeof(a));
for(ll i=2;i*2<=n;i++)
for(ll j=2;j*i<=n;j++)
a[i*j]+=i+j;
ll ans=0;
for(ll i=4;i<=n;i++)
ans+=2*a[i];
cout<<ans<<endl;
}
return 0;
}

D. 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 ...

  10. 解剖SQLSERVER 第十三篇 Integers在行压缩和页压缩里的存储格式揭秘(译)

    解剖SQLSERVER 第十三篇    Integers在行压缩和页压缩里的存储格式揭秘(译) http://improve.dk/the-anatomy-of-row-amp-page-compre ...

随机推荐

  1. 鸟哥的 Linux 私房菜Shell Scripts篇(一)

    参考: http://linux.vbird.org/linux_basic/0340bashshell-scripts.php#script_be http://www.runoob.com/lin ...

  2. pyenv离线安装python各版本

    1.问题描述: 可能是国内的网络原因,在线用pyenv安装python老是定住没反应 [root@zabbix ~]# pyenv install Downloading Python-.tar.xz ...

  3. Iptables防火墙(SNAT和DNAT)

     1.SNAT:源地址转换 实现内网访问外网,修改IP地址,使用POSTROUTING 命令:iptables  -t  nat  -A POSTROUTING  -s  192.168.1.10/2 ...

  4. 八皇后问题的Python实现和C#实现

    看到八皇后问题的解决思路, 感觉很喜欢. 我用C#实现的版本之前贴在了百度百科上(https://baike.baidu.com/item/%E5%85%AB%E7%9A%87%E5%90%8E%E9 ...

  5. Python进阶(一)

    完成慕课网的python基础学习以后,大约花了三天时间,平均每天一个小时,总结了一些比较好的例题和思想方法,下面来学习python进阶吧 参考廖雪峰官方课程 函数 python官方函数调用文档 定义默 ...

  6. 建立标准编码规则(二)-DiagnosticAnalyzer 增加诊断分析代码

    1.使用语法树 当我们要编写一个规则,例如 检测正值表达式的时候,如何编写有效的规则呢 Regex.Match("my text", @"\pXXX"); 这里 ...

  7. linux命令之 df file fsck fuser

    有非常多人说,网上非常多知识点都有了.为什么你还要在自己的博客中反复这些东西呢? 我想说的是.别人写的东西是别人理解的东西,同一时候也是别人学习过程的总结,对于自己来说.自己写自己的博客最基本的目的就 ...

  8. PHP中使用Elasticsearch

    PHP中使用Elasticsearch composer require elasticsearch/elasticsearch 会自动加载合适的版本!我的php是5.6的,它会自动加载5.3的ela ...

  9. go标准库的学习-regexp

    参考:https://studygolang.com/pkgdoc 导入方式: import "regexp" regexp包实现了正则表达式搜索. 正则表达式采用RE2语法(除了 ...

  10. day16 Python 内置函数 大体演示想看就看,会用就行

    1.abs() 获取绝对值 a = -10 print(a.__abs__()) 结果: 10 2.all()  接收一个迭代器,如果跌电气的所有元素都为真,那么返回True,否则返回False tm ...