Page 3 of 4

Re: 621

Posted: Wed May 21, 2008 8:54 am
by Obaida
I got so many WA.. But I couldn't find my mistake...
Can some body explain it.

Code: Select all

Accepted Now.

Re: 621

Posted: Wed May 21, 2008 11:50 am
by Obaida
Very Easy problem. :)
I found my mistake. Now it's Accepted in 0.000sec.
I was taking the numbers in long long int but it will be in string. Now it works well. :P

For those who are getting WA...

Posted: Fri Jun 20, 2008 12:47 pm
by zyxw
I take input as string.

My AC code:
1. Ignores invalid cases like "12345". (No blank line)
2. Prints "\n" for all test case including last one.

Hope this helps someone 8)

Re: 621 - Secret Research

Posted: Sun Sep 30, 2012 3:51 pm
by convyusboy

Code: Select all

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

using namespace std;

int TC;
string s;

int main () {
	scanf ("%s", &TC);
	while (TC --) {
		getline (cin, s);
		if (s == "1" || s == "4" || s == "78")
			printf ("+");
		else {
			int le = s.length ();
			if (le > 1 && s[le - 1] == '5' && s[le - 2] == '3')
				printf ("-");
			else if (le > 1 && s[0] == '9' && s[le - 1] == '4')
				printf ("*");
			else if (le > 2 && s[0] == '1' && s[1] == '9' && s[2] == '0')
				printf ("?");
		}		
		if (TC > 1)
			printf ("\n");
	}
	
	return 0;
}
that is my code, why do I keep getting WA?
somebody helps me please

Re: 621 - Secret Research

Posted: Mon Oct 01, 2012 9:34 pm
by brianfry713
int TC;
scanf ("%s", &TC);

Re: ACM 621

Posted: Wed Jul 31, 2013 5:57 pm
by triplemzim
jjtse wrote:
Ming Han wrote:What if you have something like "12345".

Thank You
based on the other posts I've read, you should print a newLine for that case, since it doesn't fit into any of the description.

There's no need to print a newline if the test case doesn't match the conditions... (My AC code just ignores them...)

Re: 621 - Secret Research

Posted: Thu Nov 28, 2013 2:06 pm
by abbir.ku
#include <iostream>
#include <string.h>

using namespace std;

int main()
{
string str;
int T,i,len;
char *arr;

while(cin>>T){
cin.ignore();
for(i=1;i<=T;i++){
getline(cin,str);
len = str.length();

arr = new char[len];
strcpy(arr,str.c_str());

if( ( ( arr[0] == '1' ) && ( len==1 ) ) || ( ( arr[0] == '4' ) && ( len == 1 ) ) || ( ( (arr[0] == '7') && (arr[1] == '8') && (arr[2]!='3') ) && ( len == 2 ) ) ){
cout<<"+"<<endl;
delete arr;
continue;
}else if( ( (arr[len-2] == '3') && (arr[len-1] == '5') ) ){
cout<<"-"<<endl;
delete arr;
continue;
}else if( ( (arr[0] == '9') && (arr[len-1] == '4') ) ){
cout<<"*"<<endl;
delete arr;
continue;
}else if( ( (arr[0] == '1') && (arr[1] == '9') && (arr[2] == '0') ) ){
cout<<"?"<<endl;
delete arr;
continue;
}
cout<<endl;
delete arr;
}
}

return 0;
}

why i keep getting wrong answer . please help . :(

Re: 621 - Secret Research

Posted: Tue Dec 03, 2013 2:02 am
by brianfry713
That is AC code.

Re: 621 - Secret Research

Posted: Fri Dec 13, 2013 12:45 pm
by uDebug
Here's some sample input / output.

Input:

Code: Select all

12
19035
1902342432
92342424
111
444
7777777778
78787878
1123131
1
4
78
94949435
AC Output:

Code: Select all

-
?
*
+
+
+
-

Re: 621 - Secret Research

Posted: Fri Dec 13, 2013 1:56 pm
by uDebug
why i keep getting wrong answer . please help .
Looks like you're printing useless blank lines. When I run your code with the input I gave above, I see

Code: Select all

-
?
*





+
+
+
-
However, after commenting out the "cout" like so

Code: Select all

       ...
       //cout<<endl;
       delete arr;
        }
    }
    return 0;
}
I got the same AC output as I posted above.

621-Secret Research

Posted: Thu Jun 19, 2014 8:59 pm
by Blief.S
I am getting RE though i passed every test cases...........plz.....help....

Code: Select all

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
    int n,m,i;
    char str[100];
    scanf("%d",&n);
    while(n--){
        scanf("%s",&str);
        m=strlen(str);
        char s[100];
        for(i=0;i<m;i++){
            s[i]=str[i];
        }
        if((s[0]=='1' && m==1 )|| (s[0]=='4'&& m==1 )|| (s[0]=='7' && s[1]=='8' && m==2 )) printf("+\n");
        else if(s[m-2]=='3' && s[m-1]=='5') printf("-\n");
        else if(s[0]=='9' && s[m-1]=='4') printf("*\n");
        else if(s[0]=='1' && s[1]=='9' && s[2]=='0') printf("?\n");
        else continue;


    }
    return 0;

}


Re: 621 - Secret Research

Posted: Thu Jun 19, 2014 9:29 pm
by Blief.S
6 times got RE........ plz....help...i am totally helpless to solve this...passed all cases above...

Code: Select all

Removed After AC Thanks for the help

Re: 621-Secret Research

Posted: Thu Jun 19, 2014 10:07 pm
by brianfry713
Don't double post.

Re: 621 - Secret Research

Posted: Thu Jun 19, 2014 10:25 pm
by brianfry713
Try increasing the size of s to at least 200.

Re: 621 - Secret Research

Posted: Fri Jun 20, 2014 10:47 am
by Blief.S
Thanks. I got AC