結果

問題 No.653 E869120 and Lucky Numbers
ユーザー testestesttestestest
提出日時 2018-02-25 07:03:28
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 715 bytes
コンパイル時間 114 ms
コンパイル使用メモリ 29,952 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 02:24:40
合計ジャッジ時間 1,122 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'main':
main.c:3:9: warning: implicit declaration of function 'gets' [-Wimplicit-function-declaration]
    3 |         gets(s);
      |         ^~~~
main.c:4:15: warning: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
    4 |         int i=strlen(s)-1;
      |               ^~~~~~
main.c:1:1: note: include '<string.h>' or provide a declaration of 'strlen'
  +++ |+#include <string.h>
    1 | int main(){
main.c:4:15: warning: incompatible implicit declaration of built-in function 'strlen' [-Wbuiltin-declaration-mismatch]
    4 |         int i=strlen(s)-1;
      |               ^~~~~~
main.c:4:15: note: include '<string.h>' or provide a declaration of 'strlen'
main.c:8:17: warning: implicit declaration of function 'puts' [-Wimplicit-function-declaration]
    8 |                 puts("NO");
      |                 ^~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'puts'
  +++ |+#include <stdio.h>
    1 | int main(){
/usr/bin/ld: /tmp/ccNbT67l.o: in function `main':
main.c:(.text.startup+0x12): 警告: the `gets' function is dangerous and should not be used.

ソースコード

diff #

int main(){
	char s[20010];
	gets(s);
	int i=strlen(s)-1;
	
	//最後の文字が2,3,4かチェック
	if(s[i]!='2'&&s[i]!='3'&&s[i]!='4'){
		puts("NO");
		return 0;
	}

	i--;
	//3,4,5の繰り返しを飛ばす
	while(i>=0&&(s[i]=='3'||s[i]=='4'||s[i]=='5'))i--;

	//先頭まで来てたらダメ
	if(i<0){
		puts("NO");
		return 0;
	}
	
	//次が1なら前者のパターン
	if(i==0&&s[i]=='1'){
		puts("YES");
		return 0;
	}

	//次が7,8なら後者のパターン
	if(s[i]=='7'||s[i]=='8'){
		i--;
		//6,7の繰り返しを飛ばす
		while(i>=0&&(s[i]=='6'||s[i]=='7'))i--;
		//先頭まで来てたらOK
		if(i<0)puts("YES");
		else puts("NO");
	}

	//どちらでもなければだめ
	puts("NO");
}
			  
0