結果
問題 | No.423 ハムスター語初級(数詞) |
ユーザー |
![]() |
提出日時 | 2018-09-22 23:11:30 |
言語 | C (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,210 bytes |
コンパイル時間 | 126 ms |
コンパイル使用メモリ | 29,568 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 04:23:18 |
合計ジャッジ時間 | 693 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 6 WA * 3 |
ソースコード
#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] == 1){ printf("hamu"); }else if(num[l] == 0){ printf("ham"); } } printf("\n"); return 0; }