結果

問題 No.653 E869120 and Lucky Numbers
ユーザー testestesttestestest
提出日時 2018-02-25 07:06:03
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 722 bytes
コンパイル時間 536 ms
コンパイル使用メモリ 28,052 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-11 19:26:09
合計ジャッジ時間 1,720 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,348 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 0 ms
4,352 KB
testcase_07 AC 0 ms
4,348 KB
testcase_08 AC 0 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 0 ms
4,348 KB
testcase_11 AC 0 ms
4,352 KB
testcase_12 AC 1 ms
4,352 KB
testcase_13 AC 0 ms
4,348 KB
testcase_14 AC 1 ms
4,352 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 0 ms
4,352 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 1 ms
4,352 KB
testcase_19 AC 0 ms
4,348 KB
testcase_20 AC 1 ms
4,352 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 0 ms
4,352 KB
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 1 ms
4,348 KB
testcase_26 AC 0 ms
4,352 KB
testcase_27 AC 1 ms
4,348 KB
testcase_28 AC 0 ms
4,348 KB
testcase_29 AC 0 ms
4,352 KB
testcase_30 AC 0 ms
4,348 KB
testcase_31 AC 1 ms
4,352 KB
testcase_32 AC 1 ms
4,348 KB
testcase_33 AC 0 ms
4,352 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘main’ 内:
main.c:3:9: 警告: 関数 ‘gets’ の暗黙的な宣言です [-Wimplicit-function-declaration]
    3 |         gets(s);
      |         ^~~~
main.c:4:15: 警告: 関数 ‘strlen’ の暗黙的な宣言です [-Wimplicit-function-declaration]
    4 |         int i=strlen(s)-1;
      |               ^~~~~~
main.c:1:1: 備考: include ‘<string.h>’ or provide a declaration of ‘strlen’
  +++ |+#include <string.h>
    1 | int main(){
main.c:4:15: 警告: 組み込み関数 ‘strlen’ の互換性がない暗黙的な宣言です [-Wbuiltin-declaration-mismatch]
    4 |         int i=strlen(s)-1;
      |               ^~~~~~
main.c:4:15: 備考: include ‘<string.h>’ or provide a declaration of ‘strlen’
main.c:8:17: 警告: 関数 ‘puts’ の暗黙的な宣言です [-Wimplicit-function-declaration]
    8 |                 puts("No");
      |                 ^~~~
main.c:1:1: 備考: include ‘<stdio.h>’ or provide a declaration of ‘puts’
  +++ |+#include <stdio.h>
    1 | int main(){
/tmp/ccYYcQx9.o: In function `main':
main.c:(.text.startup+0xf): warning: 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");
		return 0;
	}

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