結果
| 問題 | 
                            No.2853 A + B Problem
                             | 
                    
| コンテスト | |
| ユーザー | 
                             nekoti
                         | 
                    
| 提出日時 | 2024-08-25 15:50:44 | 
| 言語 | C  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 830 bytes | 
| コンパイル時間 | 344 ms | 
| コンパイル使用メモリ | 30,208 KB | 
| 実行使用メモリ | 8,480 KB | 
| 最終ジャッジ日時 | 2024-08-25 15:50:50 | 
| 合計ジャッジ時間 | 4,342 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 20 TLE * 1 -- * 9 | 
ソースコード
#define _DEBUG 0
#include<stdio.h>
#include<stdbool.h>
#include<string.h>
#include<stdlib.h>
int main(void)
{
  int scan;//scanf警告用
  int i,j;
  
  int n;scan=scanf("%d",&n);
  int bitcount=0;
  int bit=n;
  while(bit)
  {
    if(bit%2)bitcount++;
    bit>>=1;
  }
#if _DEBUG
    printf("bitcount = %d\n\n",bitcount);
#endif
  
  long long nn=bitcount;
  long long rr;
  long long sum=0;
  long long nCr;
  for(i=1; i<=nn/2; i++)
  {
    //
    nCr=1;
    rr=nn-i;
    //
    long long loop;
    for(loop=1;loop<=rr;loop++)
    {
      nCr = nCr*(nn-loop+1)/loop;
    }
    
    //
    if(i==bitcount-i);
    else nCr*=2;
    
    //
    sum+=nCr;
#if _DEBUG
    printf("i=%d, nn=%lld, r=%lld\n",i,nn,rr);
    printf("%dC%d=%lld\n",nn,rr,nCr);
    printf("sum=%lld\n\n",sum);
#endif
  }
  printf("%lld",sum);
  return 0;
}
            
            
            
        
            
nekoti