428 - Swamp County Roofs

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
suman
New poster
Posts: 45
Joined: Fri Oct 19, 2001 2:00 am
Contact:

Post by suman » Wed Jan 16, 2002 11:12 am

I think my calculations are ok. But there may be any trick cause my program WA. please help.


- Suman

Adrian Kuegel
Guru
Posts: 724
Joined: Wed Dec 19, 2001 2:00 am
Location: Germany

Post by Adrian Kuegel » Wed Jan 16, 2002 11:38 am

The input can be like this:
100

10 10 10
60 10

10 10 60
(values like sample input)

suman
New poster
Posts: 45
Joined: Fri Oct 19, 2001 2:00 am
Contact:

Post by suman » Thu Jan 17, 2002 7:32 pm

Then how can I understand the input finished? Moreover, are the Angles within the limit 180 to -180 ?
Thanks in advance.


- Suman

Adrian Kuegel
Guru
Posts: 724
Joined: Wed Dec 19, 2001 2:00 am
Location: Germany

Post by Adrian Kuegel » Fri Jan 18, 2002 1:01 pm

If you have read a multiple of 4 Values and you reach a blank line, then you know the description of the lot has ended (Be careful to read at least 4 Values).
I think the angles are within this range, since I had not to worry about this.

boatfish
New poster
Posts: 18
Joined: Thu May 08, 2003 11:46 am

Why WA for 428?

Post by boatfish » Wed Sep 10, 2003 2:34 pm

This is really a simple question, but I keep getting WA.
Here is my code, what's wrong?
[cpp]#include<iostream>
#include<math.h>
using namespace std;

long double pi=2*acos(0);

long double roof(long double base,long double ridge,long double between){
return (base+ridge)*between/2;
}

int main(){
int case_no=0;
long double lot,thisroof,baseline,ridgeline,between,incline,roof_area,floor_area,total_roof=0,total_area=0,total_lot=0;
char bu;
cout<<"Roof Area Floor Area % Covered\n--------- ---------- ---------\n";

while(cin>>lot){
case_no++;
roof_area=0;
floor_area=0;
while(cin.peek()!='\n' && cin.peek()!=EOF){
cin>>baseline>>ridgeline>>between>>incline;
cin.get(bu);
thisroof=roof(baseline,ridgeline,between);
roof_area+=thisroof;
floor_area+=thisroof*cos(incline*pi/180.0);
}
cout.precision(2);
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.width(9);
cout<<roof_area;
cout.width(15);
cout<<floor_area;
cout.width(13);
cout<<floor_area*100.0/lot<<"%\n";
total_roof+=roof_area;
total_area+=floor_area;
total_lot+=lot;
}
cout<<"\nTotal surface area of roofs";
cout.width(12);
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout<<total_roof<<endl;
cout<<"Total area covered by roofs";
cout.width(12);
cout<<total_area<<endl<<"Percentage of total area covered by roofs";
cout.width(8);
cout<<total_area*100.0/total_lot<<"%\nAverage roof surface area per lot";
cout.width(16);
cout<<total_roof/case_no<<endl<<"Average floor space covered per lot";
cout.width(14);
cout<<total_area/case_no<<endl;
return 0;
}
[/cpp]

MrMDRogers
New poster
Posts: 1
Joined: Fri Oct 26, 2007 3:11 am

428 - Swamp County Roofs

Post by MrMDRogers » Fri Oct 26, 2007 3:15 am

I've been beating myself up about this problem because it's fairly easy but I keep getting the wrong answer. I believe it has to do with a simple case I'm not considering... If anyone could post some sample input for me to test, I'm sure I could find the problem and I would be much appreciative. :D

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 428, WA...

Post by brianfry713 » Tue May 15, 2012 5:03 am

Input:

Code: Select all

100 10 10 10 60
10 10 10 60

200 5 10.5 5 30  10 10 7.5 45

100 

10 10 10 
60 10 

10 10 60

200 5 10.5 5 30  10 10 7.5 45

100 0 10 7.5 45 10
0 7.5 -135

300

AC output:

Code: Select all

Roof Area     Floor Area     % Covered
---------     ----------     ---------
   200.00         100.00       100.00%
   113.75          86.59        43.30%
     0.00           0.00         0.00%
   600.00         590.88      5908.85%
  7701.25        7133.96     71339.57%
     0.00           0.00         0.00%

Total surface area of roofs     8615.00
Total area covered by roofs     7911.43
Percentage of total area covered by roofs 1098.81%
Average roof surface area per lot         1435.83
Average floor space covered per lot       1318.57
Check input and AC output for thousands of problems on uDebug!

metaphysis
Experienced poster
Posts: 139
Joined: Wed May 18, 2011 3:04 pm

Re: 428 - Swamp County Roofs

Post by metaphysis » Thu Aug 04, 2016 10:27 am

The input format is not so friendly.

Post Reply

Return to “Volume 4 (400-499)”