結果

問題 No.423 ハムスター語初級(数詞)
ユーザー monburan_0401monburan_0401
提出日時 2018-09-22 23:16:07
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 1,285 bytes
コンパイル時間 610 ms
コンパイル使用メモリ 28,632 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-26 09:36:09
合計ジャッジ時間 774 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 0 ms
4,376 KB
testcase_02 AC 0 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 0 ms
4,376 KB
testcase_05 AC 0 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 0 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <string.h>
int main(void){
    char n[51];     //  入力
    int num[18];   //  2進数表記
    int i = 0;      //  添字
    int count = 0;  //  num[]用の添字  

    scanf("%s",n);

    //  'hamu' = 1; 'ham' = 0;
    while(n[i] != 0){
        if( strncmp(&n[i],"hamu",4) == 0 ){
            num[count] = 1;    //  1
            i += 3;
        }else{
            num[count] = 0;    //  0
            i += 2;
        }
        count++;
        i++;
    }

    //  check ok
    /*for(int j = 0; j < count; j++){
        printf("%d",num[j]);
    }
    printf("\n");
    */

    //  double num
    for(int k = 0; k < count; k++){
        num[k] *= 2;
        if((num[k] == 2)&&(k != 0)){
            num[k] = 0;
            num[k-1]++;
        }
    }
    
    //  check ok
    /*for(int j = 0; j < count; j++){
        printf("%d",num[j]);
    }
    printf("\n");
    */

    //  1 = 'hamu'; 0 = 'ham';
    for(int l = 0; l < count; l++){
        if((num[l] == 2)&&(l == 0)){
            printf("hamuham");
        }else if((num[l] == 3)&&(l == 0)){
            printf("hamuhamu");
        }else if(num[l] == 1){
            printf("hamu");
        }else if(num[l] == 0){
            printf("ham");
        }
    }
    printf("\n");

    return 0;
}
0