You are given an integer sequence 1,2,…,n1,2,…,n. You have to divide it into two sets AA and BB in such a way that each element belongs to exactly one set and |sum(A)−sum(B)||sum(A)−sum(B)| is minimum possible.

The value |x||x| is the absolute value of xx and sum(S)sum(S) is the sum of elements of the set SS.

Input
The first line of the input contains one integer nn (1≤n≤2⋅1091≤n≤2⋅109).

Output
Print one integer — the minimum possible value of |sum(A)−sum(B)||sum(A)−sum(B)| if you divide the initial sequence 1,2,…,n1,2,…,n into two sets AA and BB.

Examples
Input
3
Output
0
Input
5
Output
1
Input
6
Output
1
Note
Some (not all) possible answers to examples:

In the first example you can divide the initial sequence into sets A={1,2} and B={3} so the answer is 00.

In the second example you can divide the initial sequence into sets A={1,3,4} and B={2,5} so the answer is 11.

In the third example you can divide the initial sequence into sets A={1,4,5}and B={2,3,6} so the answer is 11.

解题思路:先求出前n项的和,如果前n项和为偶数,则总能找到两个子集的和相等;若为奇数,则总能找到两个子集和相差为1.

include<stdio.h>

int main()
{
long long n,ans;
while(~scanf("%lld",&n))
{
ans=(1+n)*n/2;
if(ans%2==1)
printf("1\n");
else if(ans%2==0)
printf("0\n");
}
}

CodeForces - 1102A的更多相关文章

  1. Integer Sequence Dividing CodeForces - 1102A (规律)

    You are given an integer sequence 1,2,…,n1,2,…,n. You have to divide it into two sets AAand BB in su ...

  2. CodeForces - 1102A(思维题)

    https://vjudge.net/problem/2135388/origin Describe You are given an integer sequence 1,2,-,n. You ha ...

  3. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  4. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  5. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  6. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  7. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  8. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  9. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

随机推荐

  1. Dev_GridView获取所选行的句柄

    这是官方帮助文档上的一句话: 此示例演示如何获取所选行,然后更改其字段值. GetSelectedRows方法检索所选行的句柄. 由于行句柄反映了在View中显示行的顺序,因此修改单行可 能会影响其他 ...

  2. HTTP &RFC

    HTTP 1,HTTP所表达的控制以及描述性相关的信息都包含在了HTTP的起始行和首部之中.BNF的使用使得自己能够清晰的梳理出起始行和首部中所有类别的元信息.对于每一类的元信息具体包含哪些内容也能够 ...

  3. JMter随记

    线程组( Threads (Users))理解:一个虚拟用户组,线程组内线程数量在运行过程中不会发生改变. 注意事项:线程间变量相互独立. 一个测试计划内可以包含多个线程组. 可定义内容: 取样器错误 ...

  4. 解决:vue项目中多个echarts图表只有最后一个随浏览器变化改变大小

    window.onresize = () => { this.initChart()} 改为 window.addEventListener('resize', () => { this. ...

  5. SQL 序列-DML-DML-数据类型-用户管理、权限-事务-视图

    --DML--insert关键字--作用:往表中插入一条(多条)记录 --元祖(tuple)值式的插入(一次插入一条记录)--语法1:insert into tablename(column1,col ...

  6. set和 map 数据结构

    set/map数据结构 创建: var  s=new Set(); 添加成员 s.add(1) 遍历 for of s.froEach 删除 s.delete() 判断存在 s.has() 清除 s. ...

  7. springBoot生成日志文件

    一.安装lombok 说明: 安装bomlok后model可以不用写get.set方法,slf4j日志直接使用log打印 1. Maven Repository中下载lombok.jar 2. 将lo ...

  8. instrument 之 core animation

    1.Color Blended Layers 图层混合 需要消耗一定的GPU资源,避免设置alpha小于1,省去不必要的运算 2.Color Hits Green and Misses Red 光栅化 ...

  9. Google Colab Free GPU Tutorial【转载】

    转自:https://medium.com/deep-learning-turkey/google-colab-free-gpu-tutorial-e113627b9f5d 1.Google Cola ...

  10. 部署的docker image总是太大,怎么办?

    sudo docker images REPOSITORY                        TAG                 IMAGE ID            CREATED ...