488 - Triangle Wave
Moderator: Board moderators
-
- A great helper
- Posts: 383
- Joined: Mon Oct 18, 2004 8:25 am
- Location: Bangladesh
- Contact:
-
- New poster
- Posts: 19
- Joined: Fri Sep 05, 2008 6:39 pm
- Location: bangladesh
- Contact:
488 - Triangle Wave
#include<stdio.h>
int main(){
int i,j,n,f,k.l,cas;
scanf("%d",&cas);
while(cas){
scanf("%d %d",&n,&f);
while(f){
for(i=1;i<=n;i++){
for(j=0;j<i;j++){
printf("%d",i);
}
printf("\n");
}
for(k=n-1;k>0;k--){
for(l=0;l<k;l++){
printf("%d",k);
}
printf("\n");
}
f--;
if(f!=0)
printf("\n");
}
cas--;
}
return 0;
}
int main(){
int i,j,n,f,k.l,cas;
scanf("%d",&cas);
while(cas){
scanf("%d %d",&n,&f);
while(f){
for(i=1;i<=n;i++){
for(j=0;j<i;j++){
printf("%d",i);
}
printf("\n");
}
for(k=n-1;k>0;k--){
for(l=0;l<k;l++){
printf("%d",k);
}
printf("\n");
}
f--;
if(f!=0)
printf("\n");
}
cas--;
}
return 0;
}
-
- New poster
- Posts: 13
- Joined: Mon Sep 08, 2008 6:57 pm
- Location: State University of Bangladesh
Re: 488wa!!!!!!!please help me!!!!!!!!where is the problem
You must print blank lines between testcases also....
read the problem statement again carefully.....
read the problem statement again carefully.....
Never think too hard, let ideas come to you...
Re: WA 488
where is the mistake?i m continuously getting wrong answer
#include<stdio.h>
int main()
{
int i,j,k,l,x,y,n;
scanf("%d",&n);
for(i=1;i<=n;i++)
{ printf("\n");
scanf("%d",&x);
scanf("%d",&y);
for(j=1;j<=y;j++)
{
for(k=1;k<=x;k++)
{
for(l=1;l<=k;l++)printf("%d",k);
printf("\n");
}
for(k=x-1;k>=1;k--)
{
for(l=1;l<=k;l++)printf("%d",k);
if(j!=y||k!=1)printf("\n");
}
if(j!=y)printf("\n");
}
}
return 0;
}
#include<stdio.h>
int main()
{
int i,j,k,l,x,y,n;
scanf("%d",&n);
for(i=1;i<=n;i++)
{ printf("\n");
scanf("%d",&x);
scanf("%d",&y);
for(j=1;j<=y;j++)
{
for(k=1;k<=x;k++)
{
for(l=1;l<=k;l++)printf("%d",k);
printf("\n");
}
for(k=x-1;k>=1;k--)
{
for(l=1;l<=k;l++)printf("%d",k);
if(j!=y||k!=1)printf("\n");
}
if(j!=y)printf("\n");
}
}
return 0;
}
Re: 488 TLE
WA here could any one check this pls
#include<iostream>
using namespace std;
int main()
{
int noofcases;
char *s[9]={"1","22","333","4444","55555","666666","7777777","88888888","999999999"};
int flag=0;
cin>>noofcases;
while(noofcases)
{
noofcases--;
if(!flag)cout<<"\n";
flag=1;
int n,f;
cin>>n>>f;
for(int i=0;i<f;i++){
for(int j=0;j<n;j++){
cout<<s[j];
cout<<"\n";
}
for(int j=n-2;j>=0;j--){
cout<<s[j];
cout<<"\n";
}
}
}
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int noofcases;
char *s[9]={"1","22","333","4444","55555","666666","7777777","88888888","999999999"};
int flag=0;
cin>>noofcases;
while(noofcases)
{
noofcases--;
if(!flag)cout<<"\n";
flag=1;
int n,f;
cin>>n>>f;
for(int i=0;i<f;i++){
for(int j=0;j<n;j++){
cout<<s[j];
cout<<"\n";
}
for(int j=n-2;j>=0;j--){
cout<<s[j];
cout<<"\n";
}
}
}
return 0;
}
Re: 488 TLE
To vinocit
Problem says:
Problem says:
See the output format.NOTE: There is a blank line after each separate waveform, excluding the last one.
Re: 488 TLE
Thanks a lot i got AC
Re: WA 488
pls tell me why i'm getting WA..
#include<stdio.h>
int main()
{
long long int n,i=0,k,j,m,p;
scanf("%lld",&n);
while(i<n)
{
printf("\n");
scanf("%lld\n%lld",&m,&p);
printf("\n");
int o=0;
while(o<p)
{
for(j=1;j<=m;j++)
{
for(k=1;k<=j;k++)
printf("%lld",j);
printf("\n");
}
for(j=m-1;j>=1;j--)
{
for(k=1;k<=j;k++)
printf("%lld",j);
printf("\n");
}
o++;
if(o!=p) printf("\n");
}
i++;
}
return 0;
}
i realy need ur help..
#include<stdio.h>
int main()
{
long long int n,i=0,k,j,m,p;
scanf("%lld",&n);
while(i<n)
{
printf("\n");
scanf("%lld\n%lld",&m,&p);
printf("\n");
int o=0;
while(o<p)
{
for(j=1;j<=m;j++)
{
for(k=1;k<=j;k++)
printf("%lld",j);
printf("\n");
}
for(j=m-1;j>=1;j--)
{
for(k=1;k<=j;k++)
printf("%lld",j);
printf("\n");
}
o++;
if(o!=p) printf("\n");
}
i++;
}
return 0;
}
i realy need ur help..
Re: 488wa!!!!!!!please help me!!!!!!!!where is the problem
Why i got WA in this problem ???????
why why why ?
i cant understand ..
pls help me.......
why why why ?
i cant understand ..
pls help me.......
Code: Select all
removed after AC..
Last edited by pok on Sat Dec 20, 2008 10:47 pm, edited 1 time in total.
-
- Learning poster
- Posts: 78
- Joined: Sun Nov 30, 2008 5:00 pm
- Location: IUT-OIC, Dhaka, Bangladesh
Re: 488wa!!!!!!!please help me!!!!!!!!where is the problem
Change this portion of your code:
into this:
That will do.
Code: Select all
printf("\n");
scanf("%lld\n%lld",&m,&p);
printf("\n");
Code: Select all
scanf("%lld\n%lld",&m,&p);
if(i!=0) printf("\n");
May be tomorrow is a better day............
Re: 488wa!!!!!!!please help me!!!!!!!!where is the problem
Thanks.. Articuno..
take care..
God bless you..
take care..
God bless you..
-
- New poster
- Posts: 19
- Joined: Fri Sep 05, 2008 6:39 pm
- Location: bangladesh
- Contact:
Re: 488wa!!!!!!!please help me!!!!!!!!where is the problem
i have got ac......... i had missed it
((((The outputs of two consecutive cases will be separated by a blank line.)))
-
- Experienced poster
- Posts: 136
- Joined: Sat Nov 29, 2008 8:01 am
- Location: narayangong,bangladesh.
- Contact:
Re: 488 problem
whats wrong with my code??
WA.
#include<stdio.h>
int main()
{
int amp,freq;
int ncase,i,k,l;
scanf("%d",&ncase);
while(ncase>0)
{
scanf("\n\n%d",&);
scanf("\n%d",&freq);
for(i=1;i<=freq;i++)
{
for(k=1;k<=amp;k++)
{
printf("%d",k);
for(l=1;l<k;l++)
{
printf("%d",k);
}
printf("\n");
}
for(k=amp-1;k>0;k--)
{
printf("%d",k);
for(l=1;l<k;l++)
{
printf("%d",k);
}
printf("\n");
}
if(i<freq)
printf("\n");
}
ncase--;
}
return 0;
}
WA.
#include<stdio.h>
int main()
{
int amp,freq;
int ncase,i,k,l;
scanf("%d",&ncase);
while(ncase>0)
{
scanf("\n\n%d",&);
scanf("\n%d",&freq);
for(i=1;i<=freq;i++)
{
for(k=1;k<=amp;k++)
{
printf("%d",k);
for(l=1;l<k;l++)
{
printf("%d",k);
}
printf("\n");
}
for(k=amp-1;k>0;k--)
{
printf("%d",k);
for(l=1;l<k;l++)
{
printf("%d",k);
}
printf("\n");
}
if(i<freq)
printf("\n");
}
ncase--;
}
return 0;
}
Life is more complicated than algorithm.
http://felix-halim.net/uva/hunting.php?id=32359
For Hints: http://salimsazzad.wordpress.com
http://felix-halim.net/uva/hunting.php?id=32359
For Hints: http://salimsazzad.wordpress.com
Re: 488wa!!!!!!!please help me!!!!!!!!where is the problem
Where is the problem??
?
#include <stdio.h>
#include <stdlib.h>
main()
{
int t, ax, ay, fx, k = 1, tx = 0, ty = 0;
scanf(" %d", &t);
int a[t], f[t];
printf("\n");
while(tx < t)
{
scanf(" %d", &a[tx]);
scanf(" %d", &f[tx]);
printf("\n");
tx++;
}
while(ty < t)
{
fx = 1;
while(fx <= f[ty])
{
k = 1;
for(ay = 1;ay < a[ty] * 2;ay++)
{
if(ay <= a[ty])
{
for(ax = 1;ax <= ay;ax++)
{
printf("%d", ay);
}
}
else
{
for(ax = a[ty] - k;ax > 0;ax--)
{
printf("%d", a[ty] - k);
}
k++;
}
printf("\n");
}
printf("\n");
fx++;
}
ty++;
}
system("PAUSE");
return 0;
}
Thanks!!!
?
#include <stdio.h>
#include <stdlib.h>
main()
{
int t, ax, ay, fx, k = 1, tx = 0, ty = 0;
scanf(" %d", &t);
int a[t], f[t];
printf("\n");
while(tx < t)
{
scanf(" %d", &a[tx]);
scanf(" %d", &f[tx]);
printf("\n");
tx++;
}
while(ty < t)
{
fx = 1;
while(fx <= f[ty])
{
k = 1;
for(ay = 1;ay < a[ty] * 2;ay++)
{
if(ay <= a[ty])
{
for(ax = 1;ax <= ay;ax++)
{
printf("%d", ay);
}
}
else
{
for(ax = a[ty] - k;ax > 0;ax--)
{
printf("%d", a[ty] - k);
}
k++;
}
printf("\n");
}
printf("\n");
fx++;
}
ty++;
}
system("PAUSE");
return 0;
}
Thanks!!!
Re: 488 TLE
Anybody could help me getting out of TLE ??
this is my code and please check it out which makes it slow....
Please reply me as soon as possible....thanx anyway...
this is my code and please check it out which makes it slow....
Code: Select all
import java.util.Scanner;
public class Main
{
public static void main (String [] sun)
{
Scanner input = new Scanner (System.in);
int n = input.nextInt();
int [] num = { 1, 22, 333, 4444, 55555, 666666, 7777777, 88888888, 999999999 };
int f, i, A, F;
while (n-->0)
{
A = input.nextInt();
F = input.nextInt();
for (f=1; f<=F; f++)
{
for (i=0; i<A; i++)
{
System.out.printf ( "%d\n", num[i]);
}
for (i=A-2; i>=0; i--)
{
System.out.printf ( "%d\n", num[i]);
}
System.out.printf ("\n");;
}
}
}
}