結果

問題 No.3 ビットすごろく
ユーザー neeet
提出日時 2017-06-16 00:34:39
言語 C
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 411 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 29,952 KB
実行使用メモリ 8,484 KB
最終ジャッジ日時 2024-09-25 03:14:47
合計ジャッジ時間 6,656 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 TLE * 1 -- * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main(void)
{
  unsigned short n, s = 1, t = 0, i = 1, j, a, b;

  scanf("%hd", &n);
  for(; !(s == n); i++){
    t = 0;
    for(j = 0; j < 16; j++)
      if(s & (1 << j))
          t++;

    if(s + t <= n)
      s += t;
    else if(s + t > n){
      s -= t;

      a = t;
      if(a == b){
        i = -1;
        break;
      }
      b = t;
    }
  }
  printf("%hd\n", i);
  return 0;
}
0