https://www.acmicpc.net/problem/1013
#include<stdio.h>
const int MAX_N = 200, f[][10] = { { 7,2,3,3,7,6,3,9,7,9 },{ 1,9,9,4,5,5,8,8,1,9 } };
int n, t, p;
char str[MAX_N + 1];
int main() {
scanf("%d", &t);
while (t--) {
scanf("%s", str);
p = 0;
for (int i = 0; str[i]; i++) p = f[str[i] - '0'][p];
puts(p == 4 || p == 5 || p == 8 ? "YES" : "NO");
}
return 0;
}
#include<cstdio>
#include<regex>
using namespace std;
int t;
char str[201];
int main() {
scanf("%d", &t);
while (t--) {
scanf("%s", str);
puts(regex_match(str, regex("(100+1+|01)+")) ? "YES" : "NO");
}
return 0;
}
댓글 없음 :
댓글 쓰기