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
Iwashere
New poster
Posts: 20 Joined: Mon Aug 11, 2003 1:50 pm
Location: Singapore
Post
by Iwashere » Sun Aug 24, 2003 3:58 am
Can anyone help me with my code. I tried it and it looked alright, but i got WA
Code: Select all
#include <stdio.h>
int amp, fre, no, i, l;
int main(){
scanf ("%d",&no);
for (; no>0; no--){
scanf("%d %d",&,&fre);
for (; fre>0; fre--){
for (i=1; i<=amp; i++){
for (l=i; l>0; l--){
printf("%d",i);
}
printf("\n");
}
for (i=amp-1; i>1; i--){
for (l=i; l>0; l--){
printf("%d",i);
}
printf("\n");
}
if ((no==1)&&(l==0)&&(fre==1)){
printf("1");
}
else{
printf("1\n\n");
}
}
}
return 0;
}
Joseph Kurniawan
Experienced poster
Posts: 136 Joined: Tue Apr 01, 2003 6:59 am
Location: Jakarta, Indonesia
Post
by Joseph Kurniawan » Mon Aug 25, 2003 9:37 am
Just change the part
[c]
}
for (i=amp-1; i>1; i--){
for (l=i; l>0; l--){
printf("%d",i);
}
printf("\n");
}
[/c]
with
[c]
}
for (i=amp-1; i>=1; i--){
for (l=i; l>0; l--){
printf("%d",i);
}
printf("\n");
}
printf("\n");
[/c]
And remove the part
[c]
if ((no==1)&&(l==0)&&(fre==1)){
printf("1");
}
else{
printf("1\n\n");
}
[/c]
And after the part
[c]
scanf("%d",&no);
[/c]
put
[c]
if(k) printf("\n\n");
else k=1;
[/c]
So you have to add one more variable.
Good Luck!!
There are 3 things one need to be successful : motivation, ability and chance. And if you're a believer, make it four : God's will.
Iwashere
New poster
Posts: 20 Joined: Mon Aug 11, 2003 1:50 pm
Location: Singapore
Post
by Iwashere » Mon Aug 25, 2003 11:05 am
Hey, I got AC, thanks for your help!
claire yan
New poster
Posts: 6 Joined: Thu Oct 02, 2003 7:02 am
Post
by claire yan » Fri Oct 03, 2003 7:00 am
i got WA and WA but i tried and tried
please please help me!!!!![cpp]
#include <iostream>
#include <stdio.h>
using namespace std;
////////////////////////////
int main()
{
int i = 0;
int j = 0;
int k = 0;
int m = 0;
int temp;
int amp[15000];
int fre[15000];
while(cin>>amp>>fre)
i = i+1;
temp = i--;
for(i = 0; i < temp; i++)
{
for(j = 0; j < fre; j++)
{
for(k=1;k <= amp;k++)
{
for(m = 1;m <= k ; m++)
cout<< k;
cout<<endl;
}
for(k = amp-1;k >= 1; k--)
{
for(m = 1;m <=k ; m++)
cout<<k;
cout<<endl;
}
cout<<endl;
}
cout<<endl;
}
return 0;
}[/cpp]
Subeen
Experienced poster
Posts: 127 Joined: Tue Nov 06, 2001 2:00 am
Location: Bangladesh
Contact:
Post
by Subeen » Fri Oct 03, 2003 2:02 pm
the problem is a multiple input problem ( blue tick ) u must consider this.
claire yan
New poster
Posts: 6 Joined: Thu Oct 02, 2003 7:02 am
Post
by claire yan » Fri Oct 03, 2003 6:56 pm
thanks a lot
i have already got AC
^^
Admus
New poster
Posts: 8 Joined: Mon Sep 29, 2003 3:13 pm
Post
by Admus » Sat Oct 04, 2003 6:02 pm
I don' know what is wrong with it
Code: Select all
const
tab:array[1..9] of string=
('1','22','333','4444','55555','666666','7777777','88888888','999999999');
var
a,i,q,n,m,j:longint;
begin
while not eof do
begin
readln(n);
readln(m);
if n>0 then
for i:=1 to m do
begin
for j:=1 to n do
writeln(tab[j]);
for j:=n-1 downto 1 do
writeln(tab[j]);
if i<>m then
writeln;
end;
end;
end.
midra
Experienced poster
Posts: 119 Joined: Fri Feb 13, 2004 7:20 am
Contact:
Post
by midra » Tue Apr 13, 2004 4:30 am
Here is my code:
[c][/c]
I can't see what is wrong with it!
if someone knows...pleas help me
Last edited by
midra on Thu Apr 15, 2004 2:51 am, edited 1 time in total.
shamim
A great helper
Posts: 498 Joined: Mon Dec 30, 2002 10:10 am
Location: Bozeman, Montana, USA
Post
by shamim » Tue Apr 13, 2004 5:41 am
This is a blue tick problem.
That is the first line of input is the number of test cases, eventhough this is not shown in the sample input.
midra
Experienced poster
Posts: 119 Joined: Fri Feb 13, 2004 7:20 am
Contact:
Post
by midra » Wed Apr 14, 2004 4:52 am
Thank you Shamin!
I finally got AC!
good bye!!!!
randomtaiwanese
New poster
Posts: 32 Joined: Fri Oct 01, 2004 10:53 pm
Post
by randomtaiwanese » Thu Nov 18, 2004 5:46 pm
[java]import java.io.IOException;
import java.util.StringTokenizer;
class Main
{
static String ReadLn()
{
byte lin[]=new byte[25];
int lg=0,car;
try
{
while(true)
{
car=System.in.read();
if ((car<0)||(car=='\n'))
break;
lin[lg++]+=car;
}
}
catch(IOException e)
{
return(null);
}
if ((car<0)&&(lg==0))
return(null);
return (new String (lin, 0, lg));
}
public static void main(String[] args)
{
Main newMain = new Main();
newMain.start();
}
void start()
{
int[][] in = new int[10000][2];
int c = 0;
int max = 0;
boolean inb = true;
String input;
while ((input=Main.ReadLn())!=null)
{
if(max==0)
max = Integer.parseInt(new StringTokenizer(input).nextToken());
else if(inb)
{
in[c][0] = Integer.parseInt(new StringTokenizer(input).nextToken());
inb = false;
}
else
{
in[c][1] = Integer.parseInt(new StringTokenizer(input).nextToken());
c++;
inb = true;
}
if(c==max)
{
for(int i=0;i<max;i++)
for(int f=0;f<in[1];f++)
{
for(int a=1;a<in[0];a++)
{
for(int t=1;t<=a;t++)
System.out.print(a);
System.out.println();
}
for(int a=in[0];a>0;a--)
{
for(int t=a;t>=1;t--)
System.out.print(a);
System.out.println();
}
if(f!=in[1]-1)
System.out.println();
}
break;
}
}
}
}[/java]
can someone please help me
Mohammad Mahmudur Rahman
Experienced poster
Posts: 154 Joined: Sat Apr 17, 2004 9:34 am
Location: EEE, BUET
Post
by Mohammad Mahmudur Rahman » Thu Nov 18, 2004 6:44 pm
Hmm, I didn't completely see your code, just a glance... It seems that you've not handled the multiple input case. Note that if u have an earlier version of problemset, the problem was marked as a blue flag problem there.
You should never take more than you give in the circle of life.
Fuad Hassan_IIUC(DC)
New poster
Posts: 18 Joined: Fri Jan 07, 2005 9:35 pm
Location: Bangladesh
Post
by Fuad Hassan_IIUC(DC) » Mon Jan 31, 2005 8:20 pm
plz help me out.
#include<stdio.h>
#include<iostream.h>
int main()
{
int a,f,i,j,k,l,m,flag;
cin>>a>>f;
flag=0;
for(i=1;i<=f;i++)
{
if(flag==1)
cout<<"\n";
for(j=1;j<=a;j++)
{
for(k=1;k<=j;k++)
cout<<j;
cout<<"\n";
}
for(l=a-1;l>=1;l--)
{
for(m=1;m<=l;m++)
cout<<l;
cout<<"\n";
}
flag=1;
}
return 0;
}
fuad
emotional blind
A great helper
Posts: 383 Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:
Post
by emotional blind » Thu Feb 03, 2005 4:14 pm
this is a multiple input problem
consider about it
did you not see the blue tick in this problem