题意 : 将从 1 ~ n 的数分成两组,要求两组和的差值尽可能小,并输出其中一组的具体选数情况

分析 : 如果将这 n 个数从大到小四个一组来进行选择的话那么差值就为 0 ,然后再来考虑 n%4 != 0 的情况。举个例子就是 n = 9 的时候,我们考虑 6 7 8 9 ,将6、9放入一组,7、8放入第二组,那么此时差值就会为 0 ,接下来再对 2 3 4 5 进行同样的取法此时差值仍为 0 ,最后剩下一个 1 ,很显然最后的最小差值应当为 1 。其实综合考虑一下 n%4 != 0 的情况只有 4 种,只有 n%3==3 or 0 的时候差值才能为 0 否则为 1,接下来只要模拟取的过程即可。

#include<bits/stdc++.h>
using namespace std;

int main(void)
{
    int n;
    while(~scanf("%d", &n)){
        ){
            puts("0\n1 3");
            continue;
        }

        == || n%==) puts(");
        ");

         *  + (n%!=);
        printf("%d ", num);

        ; i-=)
            printf();
        ==) puts(");
        == || n%==) puts(");
        else puts("");
    }

    ;
}

#452 Div2 Problem C Dividing the numbers ( 思维 || 构造 )的更多相关文章

  1. #381 Div2 Problem C Alyona and mex (思维 && 构造)

    题意 : 题目的要求是构造出一个长度为 n 的数列, 构造条件是在接下来给出的 m 个子区间中, 要求每一个子区间的mex值最大, 然后在这 m 个子区间产生的mex值中取最小的输出, 并且输出构造出 ...

  2. Codeforces Round #452 (Div. 2) C. Dividing the numbers(水)

    C. Dividing the numbers Petya has n integers: 1, 2, 3, ..., n. He wants to split these integers in t ...

  3. (Problem 21)Amicable numbers

    Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into ...

  4. Codeforces #452 Div2 F

    #452 Div2 F 题意 给出一个字符串, m 次操作,每次删除区间 \([l,r]\) 之间的字符 \(c\) ,输出最后得到的字符串. 分析 通过树状数组和二分,我们可以把给定的区间对应到在起 ...

  5. hdu4671 思维构造

    pid=4671">http://acm.hdu.edu.cn/showproblem.php? pid=4671 Problem Description Makomuno has N ...

  6. 思维/构造 HDOJ 5353 Average

    题目传送门 /* 思维/构造:赛后补的,当时觉得3题可以交差了,没想到这题也是可以做的.一看到这题就想到了UVA_11300(求最小交换数) 这题是简化版,只要判断行不行和行的方案就可以了,做法是枚举 ...

  7. #424 Div2 Problem C Jury Marks (二分 && 暴力 && std::unique && 思维)

    题目链接 :http://codeforces.com/contest/831/problem/C 题意 :选手有一个初始积分,接下来有k个裁判为他加分或减分(时间顺序给出),然后告诉你n(1< ...

  8. #431 Div2 Problem B Tell Your World (鸽巢原理 && 思维)

    链接 : http://codeforces.com/contest/849/problem/B 题意 : 给出 n 个在直角坐标系上的点,每个点的横坐标的值对应给出的顺序序数,比如 1 2 4 3 ...

  9. CF-D. Another Problem About Dividing Numbers

    Problem - D - Codeforces 题意:问能否在进行K次操作的情况下,将两个数变得相同,操作为每次选择一因子,然后除该因子. 题解:要判断该数最多能进行几次除的操作,其实就是判断这个数 ...

随机推荐

  1. suitecrm配置(nginx设置)

    suitecrm配置在nginx下的一些设置 server { listen 88; server_name 192.168.2.253; #charset koi8-r; #access_log / ...

  2. sql语句经验

    1:拼接字段模糊查询 where  aaa(字段) not like CONCAT(DATE_FORMAT(new(),"%Y-%m-%d"),'%完成%'): 2:备份表中数据导 ...

  3. django中的一对一的关系

    在django中一对一的关系其实就是在后面加上了unique=True 唯一的操作 源码就是这样的 其余的操作跟多对一的操作一样

  4. ubuntu 虚拟机安装

    ubuntu16.04.5 LTS 安装   1.下载ubuntu镜像 打开ubuntu官网镜像地址https://launchpad.net/ubuntu/+cdmirrors 在上面中搜索chin ...

  5. 使用Postwoman

    postman的脱单产品postwoman 一.安装 1.使用git进行安装: git clone https://github.com/liyasthomas/postwoman cd postwo ...

  6. MyBatis二级缓存的笔记及记录

    一.什么是二级缓存: 由于一级缓存是一次性的.临时的:每个会话都会创建一个新的:多个会话之间是不能共享的: 二级缓存用于解决一级缓存的不足:每一个“namespace”都会对应一个二级缓存:执行查询的 ...

  7. 求大组合数mod p,(p不一定为质数)

    #include<bits/stdc++.h> using namespace std; typedef long long ll; #define N 2000005 ll p; ll ...

  8. linux:服务器代理squid安装配置

    国内上往外的网站太慢,配了个香港代理服务器.如下:当前环境: centos系统.香港服务器IP(假设:59.188.71.11)检查squid是否安装:[root@localhost ~]# rpm ...

  9. mac安装卸载brew

    1.安装 访问https://brew.sh,copy图中的命令到命令行中,进行下载安装 2.卸载 官方版本的卸载: /usr/bin/ruby -e "$(curl -fsSL https ...

  10. css渐变色兼容性写法

    background: -webkit-linear-gradient(left, #0f0f0f, #0c0c0c, #272727); /* Safari 5.1 - 6.0 */ backgro ...