結果

問題 No.887 Collatz
ユーザー Artemis2718
提出日時 2019-09-30 22:54:00
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 285 bytes
コンパイル時間 403 ms
コンパイル使用メモリ 28,672 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-03 05:28:42
合計ジャッジ時間 1,247 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main(void)
{
  int n;
  int i = 0;
  int max = 0;

  scanf("%d",&n);

  max = n;
  while (n!=1) {
    if (n%2) {
      n = 3*n + 1;
    } else {
      n = n/2;
    }
    if (n > max){
      max = n;
    }
    i++;
  }

  printf("%d\n%d\n",i,max);

  return 0;
}
0