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;
}

相关文章:

  • 2022-03-04
  • 2021-12-07
  • 2022-12-23
  • 2022-02-14
  • 2021-06-26
  • 2021-12-14
  • 2021-07-22
  • 2021-07-30
猜你喜欢
  • 2021-06-14
  • 2021-06-27
  • 2022-12-23
  • 2021-12-08
  • 2021-11-14
  • 2021-06-24
  • 2022-12-23
相关资源
相似解决方案