結果
| 問題 | No.653 E869120 and Lucky Numbers |
| コンテスト | |
| ユーザー |
testestest
|
| 提出日時 | 2018-02-25 07:06:03 |
| 言語 | C(gnu17) (gcc 15.2.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 722 bytes |
| 記録 | |
| コンパイル時間 | 71 ms |
| コンパイル使用メモリ | 25,268 KB |
| 最終ジャッジ日時 | 2026-02-22 00:48:50 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.c: In function 'main':
main.c:3:9: error: implicit declaration of function 'gets' [-Wimplicit-function-declaration]
3 | gets(s);
| ^~~~
main.c:4:15: error: 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: error: 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(){
ソースコード
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");
}
testestest