You are not logged in. Please login at www.codechef.com to post your questions!

×

Problem http://www.codechef.com/problems/RRECIPE

I am not getting where I went wrong....this code seems pretty correct but when I submitted it gave wrong ans.

#include<stdio.h>
#include<string.h>
unsigned long int M=10000009;
char str[1000001]={'\0'};
int main()
{
int i,j,limit,t,flag;
unsigned long int ans=1;
scanf("%d",&t);
while(t!=0)
{
flag=0;
scanf("%s",&str);
limit=strlen(str);
for(i=0,j=limit-1;i<=j;i++,j--)
{
if(str[i]!=str[j])
{
if(str[i]!='?' && str[j]!='?')
{
printf("0\n");
flag=1;
break;
}
}
else
{
if(str[i]=='?')
ans=(ans*26)%M;
}
}
if(flag==0)
{
printf("%lld\n",ans);
}
t--;
ans=1;
}
return 0;
}

any suggestions????

asked 29 Sep '12, 12:38

rajarshi369's gravatar image

2★rajarshi369
25269
accept rate: 0%


Try printf("%ld\n",ans). You are printing a long int, not a long long int.

link

answered 29 Sep '12, 19:25

renze's gravatar image

2★renze
409412
accept rate: 17%

edited 29 Sep '12, 19:25

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×2
×1

question asked: 29 Sep '12, 12:38

question was seen: 373 times

last updated: 29 Sep '12, 19:25

Related questions