#include <stdio.h>
#include <string.h>
int tester(char *in)
{
int len = strlen(in), i, f1, f2, f3;
if (len == 3)
{
char one[]="one", two[]="two";
for (i=0, f1=0, f2=0 ; i<3 ; i++)
{
if (one[i]!=in[i]) f1++;
if (two[i]!=in[i]) f2++;
}
if (f1<2) return 1;
if (f2<2) return 2;
} else if (len == 5)
{
char three[]="three";
for (i=0, f3=0 ; i<5 ; i++)
{
if (three[i]!=in[i]) f3++;
}
if (f3<2) return 3;
}
return 0;
}
int main()
{
int test, res;
char input[100];
scanf("%d",&test);
while (test--)
{
scanf("%s",input);
res = tester(input);
printf("%d\n",res);
}
return 0;
}
Monday, October 17, 2011
[UVa] 12289 - One-Two-Three
Any efficient you know about? :(
Subscribe to:
Post Comments (Atom)
Connect Rapoo MT750S with Linux (Tested on Manjaro)
I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...
-
I like coding a lot, keeps me glued to the PC for hours. For that reason it's a need to edit the Syntax Highlighter to suit my eyes for...
-
I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...
-
Method: The problem at first glance seems too straightforward but it's not that much. Think a bit about the lines "Erin can add ...
No comments:
Post a Comment
Post your comment here. If you want to say something about programming problems, scripts, software etc, please try to be as descriptive as possible.