11962 - DNA II

All about problems in Volume 119. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
nazeen
New poster
Posts: 3
Joined: Sun Oct 29, 2006 6:16 am
Location: Dhaka, Bangladesh

11962 - DNA II

Post by nazeen » Fri Apr 22, 2011 2:27 pm

I'm getting WA though it seems to give correct output. Plz help ...

Code: Select all

removed after AC
Last edited by nazeen on Sat Apr 23, 2011 6:56 am, edited 1 time in total.

robot
New poster
Posts: 29
Joined: Sun May 24, 2009 8:39 pm

Re: 11962 - DNA-II WA

Post by robot » Fri Apr 22, 2011 10:26 pm

Hi
Nazeen you have some problem arise.
i) firstly your output format is wrong plz change ( ; -> : )
ii) you can get precision error for power funtion. so my suggest you use a linear loop for power function
iii) long long must Accepted
iv) cheek this input:
1
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
output:
Case 1: (30:1152921504606846975)


ASU(SUST) :D

nazeen
New poster
Posts: 3
Joined: Sun Oct 29, 2006 6:16 am
Location: Dhaka, Bangladesh

Re: 11962 - DNA-II WA

Post by nazeen » Sat Apr 23, 2011 6:56 am

Thanks robot.. your suggestions were helpful indeed :)

esharif
New poster
Posts: 18
Joined: Sun Jun 03, 2012 11:56 pm

why compile error in UVA compiler of 11962

Post by esharif » Sat Jun 16, 2012 2:35 pm

I'm getting continuously compile error. Though I'v replaced powr function to pow() function.
UVA sent me mail as below:

code.c: In function 'main':
code.c:25:4: warning: format '%s' expects type 'char *', but argument 2 has type 'char (*)[32]'
code.c:25:9: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result
code.o: In function `main':
code.c:(.text+0x117): undefined reference to `strrev'
collect2: ld returned 1 exit status

how can I remove these problem, let see the code:

Code: Select all

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

long long int powr(int x, int y)
{
	long long int i, j, mul=1;
	for(i=1;i<=y;i++)
		mul*=x;
	return mul;
}

int main()
{
	char str[32], ch;
	long long int n;
	int i, j, t, len;
	while(scanf("%d%c", &t, &ch)==2)
	{
		if(t<=0)
			break;
		for(j=1;j<=t;j++)
		{
			n=0;
			scanf("%s", &str);
			len=strlen(str);
			strrev(str);
			for(i=0;i<len;i++)
			{
				if(str[i]=='A')
					continue;
				else if(str[i]=='C')
					n+=powr(4, i);
				else if(str[i]=='G')
					n+=2*powr(4, i);
				else if(str[i]=='T')
					n+=3*powr(4, i);
			}
			printf("Case %d: (%d:%lld)\n", j, len, n);
		}
	}
	return 0;
}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: why compile error in UVA compiler of 11962

Post by brianfry713 » Mon Jun 18, 2012 11:16 pm

Write your own strrev function.
Check input and AC output for thousands of problems on uDebug!

esharif
New poster
Posts: 18
Joined: Sun Jun 03, 2012 11:56 pm

Re: why compile error in UVA compiler of 11962

Post by esharif » Tue Jun 19, 2012 7:31 pm

Thnx a lot, it helped me to get just AC :D

Post Reply

Return to “Volume 119 (11900-11999)”