链接

[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. sklearn datasets模块学习

    sklearn.datasets模块主要提供了一些导入.在线下载及本地生成数据集的方法,可以通过dir或help命令查看,我们会发现主要有三种形式:load_<dataset_name>. ...

  2. layui框架学习记录

    自定义layui动态渲染的数据表格单元格样式 layui.use('table', function() { var table = layui.table; table.render({ elem: ...

  3. January 20th, 2018 Week 3rd Saturday

    We may encounter many defeats but we must not be defeated. 我们可能会失败很多次,但决不能被打败. As long as we are con ...

  4. java 操作elasticsearch之搭建测试项目环境

    在创建项目之前请确认maven是否安装好,在此我是以环境都搭建好的情况下进行示范,现在以eclipse开发工具为例,具体操作如下: 1.创建maven项目 File - new -other 2.在p ...

  5. Kafka设计原理

    一.入门 1.简介 Apache Kafka是一个分布式消息发布订阅系统.它最初由LinkedIn公司基于独特的设计实现为一个分布式的提交日志系统( a distributed commit log) ...

  6. 关于使用jquery修改hover伪标签的样式

    HTML如下: <div class=".nav-subitem"> <div classs="nav-subitem-link">标题 ...

  7. Spring集成MyBatis持久层框架

    一.MyBatis介绍 MyBatis 是一款优秀的持久层框架,它支持定制化SQL.存储过程以及高级映射.MyBatis 避免了几乎所有的JDBC代码和手动设置参数以及获取结果集,可以使用简单的XML ...

  8. mysql列的处理

    MySQL 添加列,修改列,删除列 示例:ALTER TABLE tb_financial MODIFY CREATE_TIME DATETIME(3) DEFAULT NULL COMMENT '录 ...

  9. linux命令之 df file fsck fuser

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

  10. 【转】Android 创建AVD各参数详解

    一.Eclipse中图形创建AVD: Device: 即设备,指具体的手机设备型号,可以在window->Android Virtual Device Manager->Device De ...