Div 3 - SGU 105(找规律)

分析:很容易知道序列1,2,3, 4,5, 6......与3的关系就是1,2, 0,1, 2,0,......如果是在一个数后面添加一个数就变成了这种序列1, 0, 0, 1, 0, 0, 1, 0, 0.。。。

代码如下:

=======================================================================================

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;

const int MAXN = 107;
const int oo = 1e9+7;

int main()
{
    int N;

    scanf("%d", &N);

    printf("%d\n", N/3*2 + (N%3 == 2?1:0));

    return 0;
}

 

posted @ 2015-09-14 10:50  无忧望月  阅读(117)  评论(0编辑  收藏  举报
levels of contents