joj 1005 Four in a Row

http://acm.jlu.edu.cn/joj/showproblem.php?pid=1005

 判断一个数是否能用连续的四个数的和构成

解:这个数一定是偶数,并且除以2之后的商是奇数


#include <stdio.h>

 

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("tdata.txt","r",stdin);
    #endif
    int n;
    while(scanf("%d",&n),n)
    {
        if( n%2 == 0 && (n>>1)%2 == 1 )
            printf("%d is the sum of four consecutive integers.\n",n);
        else printf("%d is not the sum of four consecutive integers.\n",n);
    }
    return 0;
}

posted @ 2010-09-02 13:58  菜到不得鸟  阅读(80)  评论(0编辑  收藏  举报