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

Post Reply
Schutzstaffel
New poster
Posts: 37
Joined: Fri Apr 30, 2004 6:52 pm
Location: Portugal

Post by Schutzstaffel »

This is weird, the main change you did was to not test when it was the last wave and print the newline anyway (I kept the the multiple inputs) and of course to simplify the code that was really messy lol but the thing is I had outputs that were equals to the now AC code :o I thought maybe it would be because I tested if frequency and amplitute were 0 but I also tried without that.
Oh well it's AC now, thanks for your help and for everyone else who replied.
Posted code edited.
Image
TripShock
New poster
Posts: 14
Joined: Tue Jun 20, 2006 9:33 am

488 - Triangle Wave

Post by TripShock »

this program seems t conform to all the rules but still gets PE! help!

Code: Select all

#include <iostream>

using namespace std;

int main()
{
    short a = 0;
    short f = 0;
    short n = 0;
    
    cin >> n;
    
    while(n)
    {
        cin >> a;
        cin >> f;
    
        for(char i = 1; i <= f; i++)
        {
            for(char j = 1; j <= a; j++)
            {
                for(char k = 1; k <= j; k++)
                    cout << (int)j;
                if(a != 1)
                    cout << endl;
            }
            for(char j = a - 1; j >= 1; j--)
            {
                for(char k = 1; k <= j; k++)
                    cout << (int)j;
                cout << endl;
            }
            if(!(i == f && n == 1))
                cout << endl;
        }
        n--;
    }
    
    return 0;
}
chunyi81
A great helper
Posts: 293
Joined: Sat Jun 21, 2003 4:19 am
Location: Singapore

Post by chunyi81 »

Check the output description:
The outputs of two consecutive cases will be separated by a blank line.
NOTE: There is a blank line after each separate waveform, excluding the last one
Remove your code after you get AC.
TripShock
New poster
Posts: 14
Joined: Tue Jun 20, 2006 9:33 am

Post by TripShock »

Input:
1

3
2

Output:
1\n
22\n
333\n
22\n
1\n
\n
1\n
22\n
333\n
22\n
1\n


Should I remove the last '\n' ?
chunyi81
A great helper
Posts: 293
Joined: Sat Jun 21, 2003 4:19 am
Location: Singapore

Post by chunyi81 »

TripShock wrote:Input:
1

3
2

Output:
1\n
22\n
333\n
22\n
1\n
\n
1\n
22\n
333\n
22\n
1\n


Should I remove the last '\n' ?
Nope. In fact this is ok. Apparently I overlooked one line of code in your program which does this. But then again to get AC you have to print a blank line after each triangle wave, which is exactly what my AC program (no PE) did. I know what my AC program did does not really conform to the output description. I will leave a post in the Bugs and Suggestions forum regarding this.
TripShock
New poster
Posts: 14
Joined: Tue Jun 20, 2006 9:33 am

Post by TripShock »

I don't get it! Now i'm getting WA!!!

Code: Select all

#include <iostream>

using namespace std;

int main()
{
    short a = 0;
    short f = 0;
    short n = 0;
    
    cin >> n;
    
    while(n)
    {
        cin >> a;
        cin >> f;
    
        for(char i = 1; i <= f; i++)
        {
            for(char j = 1; j <= a; j++)
            {
                for(char k = 1; k <= j; k++)
                    cout << (int)j;
                cout << endl;
            }
            for(char j = a - 1; j >= 1; j--)
            {
                for(char k = 1; k <= j; k++)
                    cout << (int)j;
                cout << endl;
            }
            if(!(i == f && n == 1))
                cout << endl;
        }
        n--;
    }
    
    return 0;
}
newton
Experienced poster
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Location: Campus Area. Dhaka.Bangladesh
Contact:

Post by newton »

Code: Select all

code is deleted after AC


tankyou very much for the example i got AC.






newton ......................... simply the best
Last edited by newton on Thu Feb 01, 2007 7:46 am, edited 1 time in total.
helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Post by helloneo »

Try this..

Code: Select all

2

3
2

3
2

My output

Code: Select all

1
22
333
22
1

1
22
333
22
1

1
22
333
22
1

1
22
333
22
1
Last edited by helloneo on Thu Feb 15, 2007 12:25 pm, edited 2 times in total.
linux
Learning poster
Posts: 56
Joined: Sat Jul 01, 2006 12:21 pm
Location: CA-95054
Contact:

488 P.E!

Post by linux »

How this solution can give P.E I cannot imagine that's about 488, the assumed easiest problem. What's wrong with this? Plz help anyone. Plz check out the output first for my solution.
Hope to hear from you soon.

Code: Select all

#include<stdio.h>

main() {
 printf("Code removed after AC.\n");
 return 0;
}
:roll:
Last edited by linux on Sun Feb 04, 2007 11:25 am, edited 1 time in total.
Solving for fun..
helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Post by helloneo »

Search first..
Don't open a new thread if there is one already..
linux
Learning poster
Posts: 56
Joined: Sat Jul 01, 2006 12:21 pm
Location: CA-95054
Contact:

Yahoo-o-o-o-o-o-o-o-o! Got AC!

Post by linux »

Thanks everyone! The problem was for multiple cases! I got it and got AC.
:P :P :P

I opened this thread because old threads weren't enough to recognise the problem! Good luck.
Solving for fun..
newton
Experienced poster
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Location: Campus Area. Dhaka.Bangladesh
Contact:

Post by newton »

Mr LINUX.


you must delete your code after AC. Otherwise another person may copy and paste it.






best of luck.


newton......................................... simply the best!
linux
Learning poster
Posts: 56
Joined: Sat Jul 01, 2006 12:21 pm
Location: CA-95054
Contact:

AC

Post by linux »

[Removed]
Last edited by linux on Thu Sep 11, 2008 9:50 pm, edited 3 times in total.
Solving for fun..
helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Re: Days changed!

Post by helloneo »

linux wrote:Days have changed Newton! If you don't believe try the code to get AC.
I recommend it's impossible for you. Because days have changed. Try out... 8) http://acm.uva.es/problemset/author.html[/b]
No.. what newton mean is your code could be a spolier..
In this forum, we remove our code after getting AC..
And another thing, if there is a thread already, we don't open a new thread.. just using old thread to post..
newton
Experienced poster
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Location: Campus Area. Dhaka.Bangladesh
Contact:

Post by newton »

thanx.
Last edited by newton on Sat Jul 07, 2007 3:34 pm, edited 1 time in total.
Post Reply

Return to “Volume 4 (400-499)”