Integer Sequence Dividing CodeForces - 1102A(思维水题)

在这里插入图片描述

给大家说一个小技巧, 这种一看题面不是很难, 再一看复杂度1e9的题, 一定是规律题.
对于规律题大致有两种思路, 一种是正面杠, 直接通过证明推导出公式来; 第二种就是找规律啦, 毕竟我不是学数学的.
这道题目我们先列出几组数据1-8: 1 1 0 0 1 1 0 0… 基本已经发现规律了, 前n项和为奇数(即(x+1)/n)则1, 偶数则0.

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
using namespace std;
#define ms(x, n) memset(x,n,sizeof(x));
typedef  long long LL;
const LL maxn = 1e6+10;

int main()
{
    LL n;
    cin >> n;
    if(((n+1)/2)%2 == 1)
        cout << 1 << endl;
    else
        cout << 0 << endl;

	return 0;
}

猜你喜欢

转载自blog.csdn.net/a1097304791/article/details/86468334