488 - Triangle Wave
Moderator: Board moderators
-
- New poster
- Posts: 37
- Joined: Fri Apr 30, 2004 6:52 pm
- Location: Portugal
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 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.
Oh well it's AC now, thanks for your help and for everyone else who replied.
Posted code edited.
488 - Triangle Wave
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;
}
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 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' ?
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;
}
-
- Experienced poster
- Posts: 162
- Joined: Thu Jul 13, 2006 7:07 am
- Location: Campus Area. Dhaka.Bangladesh
- Contact:
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.
Try this..
My output
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.
488 P.E!
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.
Hope to hear from you soon.
Code: Select all
#include<stdio.h>
main() {
printf("Code removed after AC.\n");
return 0;
}
Last edited by linux on Sun Feb 04, 2007 11:25 am, edited 1 time in total.
Solving for fun..
Yahoo-o-o-o-o-o-o-o-o! Got AC!
Thanks everyone! The problem was for multiple cases! I got it and got AC.
I opened this thread because old threads weren't enough to recognise the problem! Good luck.
I opened this thread because old threads weren't enough to recognise the problem! Good luck.
Solving for fun..
Re: Days changed!
No.. what newton mean is your code could be a spolier..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... http://acm.uva.es/problemset/author.html[/b]
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..