#include #include int divide(char* part) { int length = 0; for (int i=0; i < sizeof(part)-1; i++) { if (part[i] != '\0') length++; } return length; } void separate(char org[2][12], char part[2][3][4], int length[2][3]) { for (int i = 0; i < 2; i++) { char* tp = strtok(org[i], "."); sprintf(part[i][0],"%s",tp); int count = 0; while (tp != NULL) { tp = strtok(NULL, "."); if (tp != NULL) { if (count++ == 0) sprintf(part[i][1], "%s", tp); else sprintf(part[i][2], "%s", tp); } } for (int j=0; j<3; j++) length[i][j] = divide(part[i][j]); } } void bigger(char part[2][3][4], int length[2][3]) { for (int i=0; i < 3; i++) { int sum[2] = {0,0}; if (length[0][i] > length[1][i]) { printf("YES\n"); return; } else if (length[0][i] == length[1][i]) { for (int j =0; j < length[0][i]; j++) sum[0] += (int) part[0][i][j]; for (int k =0; k < length[1][i]; k++) sum[1] += (int) part[1][i][k]; if (sum[0] > sum[1]) { printf("YES\n"); return; } else if (sum[0] < sum[1]) { printf("NO\n"); return; } } else { printf("NO\n"); return; } } printf("YES\n"); // 全て等しいとき } int main() { int sum[2] = {0,0}; int length[2][3] = {0}; char version[2][12]; char part[2][3][4]= {0}; scanf("%s %s",&version[0], &version[1]); separate(version, part, length); bigger(part, length); return 0; }