488 - Triangle Wave

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

Moderator: Board moderators

ranacse05
New poster
Posts: 37
Joined: Wed Mar 28, 2007 5:08 pm
Location: Rajshahi
Contact:

Post by ranacse05 »

Why output Limit E...??????


*************code removed***************
Last edited by ranacse05 on Tue Apr 24, 2007 7:46 pm, edited 1 time in total.
I like to solve problems.
Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

Check your code carefully.

Code: Select all

for(i=0;i<num;i++)
    ...
    for(k=0;k<b;k++)
        ...
        for(i=0;i<a;i++)  // i again ???
            ...
Hope it helps.
Ami ekhono shopno dekhi...
HomePage
ranacse05
New poster
Posts: 37
Joined: Wed Mar 28, 2007 5:08 pm
Location: Rajshahi
Contact:

Post by ranacse05 »

Why PE ?
plz help me
#include "stdio.h"

int main()
{
int a,b,i,j,k,num;


while(scanf("%d",&num)==1)
{
for(i=0;i<num;i++)
{
scanf("%d %d",&a,&b);
printf("\n");
for(k=0;k<b;k++)
{
for(i=0;i<a;i++)
{ for(j=0;j<i+1;j++)
printf("%d",i+1);
printf("\n");
}

for(i=a-2;i>=0;i--)
{ for(j=0;j<i+1;j++)
printf("%d",i+1);
printf("\n");
}
printf("\n");
}
printf("\n");

}
}
return 0;
}
I like to solve problems.
Rocky
Experienced poster
Posts: 124
Joined: Thu Oct 14, 2004 9:05 am

Post by Rocky »

to rana:

is u sure your programm get pe????.....i submitted it and get output limit exit....

GOOD LUCK
rocky
ranacse05
New poster
Posts: 37
Joined: Wed Mar 28, 2007 5:08 pm
Location: Rajshahi
Contact:

Post by ranacse05 »

Rocky try this :
#include "stdio.h"

int main()
{
int a,b,i,j,k,l,num,count,total;
total=0;
while(scanf("%d",&num)==1)
{
count=0;
for(l=0;l<num;l++)
{
scanf("%d %d",&a,&b);
printf("\n");
total+=b;
for(k=0;k<b;k++)
{
for(i=0;i<a;i++)
{
for(j=0;j<i+1;j++)
printf("%d",i+1);
printf("\n");
}
count++;
for(i=a-2;i>=0;i--)
{
for(j=0;j<i+1;j++)
printf("%d",i+1);
printf("\n");
}
if(count!=total)
printf("\n");
}

}
}

return 0;
}


But why PE????????????
I like to solve problems.
Rocky
Experienced poster
Posts: 124
Joined: Thu Oct 14, 2004 9:05 am

ok

Post by Rocky »

ok i check ur previous code which is ouput limit exit and it is now ok....i send it to u via pm.check it..

GOOD LUCK
rocky
m2lajoo
New poster
Posts: 11
Joined: Thu Jan 11, 2007 9:21 am
Location: iran

Post by m2lajoo »

You didn't understand the problem well
it is not EOF It has test cases
for example:
input:
1
3
2
output:

1
22
333
22
1

1
22
333
22
1
yor code doesn't go out of program but it should.
sorry for my bad english.
#include<smile.h>
regards
turcse143
Learning poster
Posts: 81
Joined: Wed May 09, 2007 9:59 pm
Location: (CSE,DU) Dhaka,Bangladesh

Here is my code & i got PE. Ples help me if any mistakes

Post by turcse143 »

#include <stdio.h>
void main(void)
{

unsigned long i,j,k,amp,freq,count,m,n,l;

count=0;
//freopen("input3.in","r",stdin);
scanf("%lu",&n);
for(l=1;l<=n;l++)
{
scanf("%lu %lu",&amp,&freq);

// if(count!=0)
//printf("\n");

if(amp==0)
{
for(i=0;i<freq;i++)
if(i!=freq-1)
// printf("\n");
// count++;
continue;
}

for(i=0;i<freq;i++)
{
//if(count!=0)
// printf("\n");

for(j=1;j<=amp;j++)
{
for(k=0;k<j;k++)
printf("%lu",j);
printf("\n");
}

for(j=amp-1;j>=1;j--)
{
for(k=0;k<j;k++)
printf("%lu",j);
if(j!=1)
printf("\n");
}
if(i==freq-1&&l==n)
continue;
else if(i!=freq-1||l!=n)
printf("\n\n");



}

//count++;
if(l!=n)
//break;
//else
printf("\n");
}


}
Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

Search the board first. Don't open a new thread if one already exists. If there is no thread then you can open a new one. But then you should specify the problem name.
Ami ekhono shopno dekhi...
HomePage
turcse143
Learning poster
Posts: 81
Joined: Wed May 09, 2007 9:59 pm
Location: (CSE,DU) Dhaka,Bangladesh

488, PE,PLES help

Post by turcse143 »

2

4
3

1
22
333
4444
333
22
1

1
22
333
4444
333
22
1

1
22
333
4444
333
22
1
3
2

1
22
333
22
1

1
22
333
22
1

Here is my code i got PE PLES Help.
Note: There is no '\n' in my output in last case. So what is the problem??
Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

Search the board first. Don't open a new thread if there is one already.
Ami ekhono shopno dekhi...
HomePage
camiloreis84
New poster
Posts: 1
Joined: Sun Jul 15, 2007 10:32 pm

Post by camiloreis84 »

I put this code e i had PE too, someone could see what's wrong?

Code: Select all

#include<stdio.h>

int main(){
  int n, amp, hz, i, j, l, k;
  
    scanf("%d", &n);
  
    for(k = 1; k <= n; k++){
      if(k > 1)
        printf("\n");
       
      scanf("%d", &amp);
      scanf("%d", &hz); 
      for(l = 1; l <= hz; l++){
        for(i = 1; i <= amp; i++){
          for(j = 1; j <= i; j++)
            printf("%d", i);
       
          printf("\n");    
        }
        for(i = amp-1; i >= 1; i--){
          for(j = 1; j <= i; j++)
            printf("%d", i);
       
          if(l == hz && i == 1 && k == n)
            continue;
          else
            printf("\n");          
        }
        if(l != hz)
          printf("\n");
        }
      
    }      
}
Sayeef
New poster
Posts: 12
Joined: Sun Jun 18, 2006 3:06 am

Post by Sayeef »

I've tried everything and still PE help plese

Code: Select all

#include<stdio.h>

main()
{
 int i,j,k,p,f=1;
 int amp=0,freq=0,test=0;
	scanf("%d",&test);
	for(p=1;p<=test;p++)
	{

	scanf("%d",&amp);
	scanf("%d",&freq);
	
	for(i=1;i<=freq;i++)
	{
		for(j=1;j<=amp;j++)
			{
			for(k=1;k<=j;k++)
				{
					printf("%d",j);

				}
				printf("\n");
			}
		for(j=amp-1;j>=1;j--)
			{
			for(k=1;k<=j;k++)
			{
				printf("%d",j);

			}
			printf("\n");
	   }
	if(i!=freq)
	  printf("\n"); 
	}
  }
 return 0;
}
rongtuli
New poster
Posts: 5
Joined: Fri Aug 17, 2007 4:38 am

Post by rongtuli »

to muhin,
omit the first two printf("\n");
by tulip
Justin darkwing
New poster
Posts: 1
Joined: Sat Nov 03, 2007 4:20 am

488 TLE

Post by Justin darkwing »

Code: Select all

#include<iostream>
using namespace std;
int main()
{
	int x,i,j,a=0,b=0,c=1;
 	cin>>x;

		while(x--)
		{
				i=0;j=0;
				cin>>i>>j;
		
			while(j--)
			{
			
				a=0;b=0;c=1;
				for(a=1;a<=i;a++)
				{
					for(b=0;b<a;b++)
					{
						 cout<<c;
			
					}
					c++;
					 cout<<endl;
				}
				c=i-1;
				for(a=i;a>0;a--)
				{
					for(b=1;b<a;b++)
					{
						cout<<c;
			
					}
					c--;
				if(c==0&j==0)continue;
				 cout<<endl;
				}
				
			}
		}
//system("pause");
	
	return 0;
}

Can anybody tell me why I got a TLE,please?????
Post Reply

Return to “Volume 4 (400-499)”