链接

[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. Python基础知识:字典

    1.字典中键-值为一对,keys()返回一个列表,包含字典中所有键,values()返回所有值 favorite_languages ={ 'jack':"python", 'al ...

  2. RD340服务器安装windows2003系统

    RD340服务器安装windows2003系统云修网

  3. el-table表格标题换行

    在做一些管理后台的项目中,表格时最常见的,当有时数据字段多时往往会用滚动条,但从用户体验角度讲,肯定需要多展示信息,那么可能需要一个单元格放多个字段,这时候表头就需要换行. 具体实现如下: // 注意 ...

  4. python第四十六课——函数重写

    3.函数重写(override) 前提:必须有继承性 原因: 父类中的功能(函数),子类需要用,但是父类中函数的函数体内容和我现在要执行的逻辑还不相符 那么可以将函数名保留(功能还是此功能),但是将函 ...

  5. redis类与用法

    <?phpnamespace app\common\model; class Cache { public $redis = null; public function __construct( ...

  6. php 对象数组互转

    数组转对象 function array2object($array) {   if (is_array($array)) {     $obj = new StdClass();     forea ...

  7. Zookeeper安装及运行

    zookeeper的安装分为三种模式:单机模式.集群模式和伪集群模式. 单机模式 首先,从Apache官网下载一个Zookeeper稳定版本,本次教程采用的是zookeeper-3.4.9版本. ht ...

  8. 蒟蒻qxt的sd'日常

    emm... 今天刷了一道水题 居然 死循环了 真的是水题啊 顿时自闭 (救救孩子吧) 结果 bug是 我把for循环中的i的值改变了 使得i的值一直都不会达到他的边界值 于是就死循环了 所以 要用到 ...

  9. C语言程序设计II—第五周教学

    第五周教学总结(25/3-31/3) 教学内容 本周的教学内容为:第七章 数组 7.3 字符串. 课前准备 在博客园发布作业:2019春第五周作业 第四周作业讲解视频:A Programing Vid ...

  10. Android TextView的属性设置为textstyle="bold"时 中文的“¥”不显示

    昨天在修改列表的时候出现了一个挺让人纠结的问题.在TextView中“¥”符号无论如何也显示不出来.尝试了使用气的特殊符号,都是能够正确显示的. 最后百度google了一圈也没找出个所以然来.于是觉得 ...