結果

問題 No.887 Collatz
ユーザー kidhrnkidhrn
提出日時 2020-03-03 15:19:52
言語 C
(gcc 12.3.0)
結果
RE  
実行時間 -
コード長 348 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 29,440 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 00:05:43
合計ジャッジ時間 3,372 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 RE -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 WA -
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 0 ms
5,376 KB
testcase_14 WA -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 WA -
testcase_20 RE -
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 RE -
testcase_25 AC 0 ms
5,376 KB
testcase_26 RE -
testcase_27 AC 1 ms
5,376 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>

int main(void) {
    
    int n[100];
    scanf("%d",&n[0]);

    int max=0;
    int i;
    
    for(i=0;n[i]!=1;i++){
        if(n[i]%2!=0){
            n[i+1] = 3*n[i]+1; }
        else{
            n[i+1] = n[i]/2; }
        if(n[i+1]>max)max=n[i+1];
        
    }
    
    printf("%d\n%d\n",i,max);
   
    
    return 0;
}
0