11309 - Counting Chaos

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

Moderator: Board moderators

saman_saadi
New poster
Posts: 31
Joined: Sun Feb 25, 2007 6:33 pm
Location: Tehran

Post by saman_saadi »

srrajesh wrote:
saman_saadi wrote: At last I found your bug! yes in my machine your program for 01:20 output 02:22 as Robert Gerbicz's machine. The problem is in isPal function. You forgot add '\0' in str so after str[3] = s[4]; you must add str[4] = '\0'; and you will get AC. Please after getting AC remove your code
Thanks a million, for that!
Now I got AC!
I really feel embarrassing abt what I had done!!! :-?

Just curious to know, what is ur machine type, OS and compiler?
My IDE is Code::Blocks and my default compiler is gcc and my OS is Windows XP but your bug doesn't depend on operating system or compiler:
It is important to preserve the NULL terminating character as it is how C defines and manages variable length strings. All the C standard library functions require this for successful operation
for more information you can try http://www.cs.cf.ac.uk/Dave/C/node19.html. So your code mabye work correctly or not
Last edited by saman_saadi on Mon Oct 08, 2007 10:39 pm, edited 1 time in total.
baodog
Experienced poster
Posts: 202
Joined: Wed Jul 04, 2007 6:53 am

Post by baodog »

To saman_saadi,
You ask for code removing, but
you also have to remove the code from your "quote" on page one as well.
It's not automatically changed (not dynamically linked).
reza_cse08
New poster
Posts: 8
Joined: Sun Nov 17, 2013 9:55 pm

WA: 11309 - Counting Chaos

Post by reza_cse08 »

Why I got wrong answeer. please help anyone
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<cstdio>

using namespace std;

int main ()
{
int i, j, t, x, m, n, a[10]={0};
cin>>t;
while(t--)
{
scanf("%d:%d",&m,&n);
x = 100*m+n;
while(1)
{
x++;
if(x%100==60)
{
x +=40;
}
if(x==2400)
{
x = 0;
}
int tt = x;
i = 1;
while(tt!=0)
{
a[i++] = tt%10;
tt = tt/10;
}
for(j =1; j<=((i-1)/2);j++)
{
if(a[j]==a[i-j])
{
continue;
}
else
{
break;
}
}
if(j==((i+1)/2))
{
break;
}
}
cout<<a[4]<<a[3]<<":"<<a[2]<<a[1]<<endl;

memset(a,0,sizeof(a));
}
return 0;
}
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11309 - Counting Chaos

Post by brianfry713 »

Try the I/O in this thread.
Check input and AC output for thousands of problems on uDebug!
Post Reply

Return to “Volume 113 (11300-11399)”