Uva 621:Secret Research

Problem Link


A hard tiring problem !Many loopholes,many many,use http://www.udebug.com

<Source Code>

#include<stdio.h>
#include<string.h>
int main()
{
char a[10000];int n,t,l,i;
scanf(“%d%*c”,&t);
i=1;while(t–)
{l=0;
gets(a);
l=strlen(a);

if(a[0]==’9′ && a[l-1]==’4′)
printf(“*\n”);
else if((a[0]==’1’&&l==1||(l==1 && a[0]==’4′)))
printf(“+\n”);
else if(a[l-2]==’3′ &&a[l-1]==’5′)
printf(“-\n”);
else if((a[0]==’1’&&a[l-1]==’1′)||(a[0]==’1’&&a[l-1]==’4′)||(a[0]==’1’&&a[l-2]==’7’&&a[l-1]==’8′))
printf(“?\n”);
else if(a[l-2]==’7′ &&a[l-1]==’8′)
{
if(l==2)
printf(“+\n”);
else
printf(“?\n”);
}
else if(a[l-1]==’4’||a[l-1]==’1′)
{
if(a[0]==’1′ ||a[0]==’4′)
printf(“?\n”);
else
printf(“+\n”);

}
else if(a[0]==’1’&&a[1]==’9’&&a[l-1]!=’4’&&a[l-1]!=’8’&&a[l-1]!=’1’&&a[l-1]!=’5′)
printf(“?\n”);

}
return 0;
}

Advertisements

Uri 1332:One Two Three

Problem Link


<Source Code>

# include <stdio.h>
# include <string.h>
# include <ctype.h>

int main()
{
int n;
char a[7],chr;
scanf(“%d”,&n);

getchar();

while(n–)
{

gets(a);
if(strlen(a)==5)
printf(“3\n”);
else if((a[0]==’o’ && a[1]==’n’)||
(a[0]==’o’ && a[1]==’e’)||
(a[1]==’n’ && a[2]==’e’)||
(a[0]==’o’ && a[2]==’e’)||
(a[0]==’o’ && a[2]==’n’))
printf(“1\n”);
else
printf(“2\n”);

}

return 0;
}

Uri 1914:Whose Turn Is It?

Problem Link


Let’s make our turn 😉 \(^_^)/

<Source Code>

#include<stdio.h>
#include<string.h>
int main()
{
char a[1000],b[20],c[10000],d[20];
long long i,n,x,y;
scanf(“%lld”,&n);
while(n–)
{
scanf(“%s %s %s %s”,a,b,c,d);
scanf(“%lld %lld”,&x,&y);
i=x+y;
if(b[0]==’P’)
{
if(i%2==0)
printf(“%s\n”,a);
else
printf(“%s\n”,c);

}
else
{
if(i%2==0)
printf(“%s\n”,c);
else
printf(“%s\n”,a);

}
}
return 0;
}

Uri 1234:Dancing Sentence

Problem link

 


Source Code:

#include <stdio.h>

#include <string.h>

int main()

{

char a[1000];

int i,j,k,l,n,m;

while(gets(a) != NULL)

{

k = strlen(a);

n=0;

for (i=0;i<k;i++)

{

if(a[i] != ‘ ‘)

{

n++;

if(n%2 != 0)

{

if(a[i]>=’a’ && a[i]<= ‘z’)

a[i] = a[i] – 32;

else

a[i] = a[i];

}

else

{

if(a[i]>=’A’ && a[i]<= ‘Z’)

a[i] = a[i] + 32;

else

a[i] = a[i];

}

}
}

printf(“%s\n”,a);

}
}

Uri 1943 : Top N

Problem link: 


Source Code:

#include <stdio.h>

int main(){
int n;
scanf(“%d”, &n);
if(n == 1)
printf(“Top 1\n”);
else if(n > 1 && n <= 3) printf(“Top 3\n”);
else if(n > 3 && n <= 5) printf(“Top 5\n”);
else if(n > 5 && n <= 10) printf(“Top 10\n”);
else if(n > 10 && n <= 25) printf(“Top 25\n”);
else if(n > 25 && n <= 50) printf(“Top 50\n”);
else printf(“Top 100\n”);
return 0;
}

UVa 10340:All in All

Problem Link


<Source Code>

#include<stdio.h>
#include<string.h>
int main()
{
char a1[100000],a2[100000];
while(scanf(“%s %s”,a1,a2)!=EOF){
if(strlen(a1)>strlen(a2))
printf(“No\n”);
else{
long long int index=0,i;
for(i=0;i<strlen(a2);i++)
{if(a1[index]==a2[i])
index++;
}

if(index==strlen(a1))
printf(“Yes\n”);
else
printf(“No\n”);
}
}
return 0;
}