Page 1 of 1

Posted: Wed Jan 16, 2002 11:12 am
by suman
I think my calculations are ok. But there may be any trick cause my program WA. please help.


- Suman

Posted: Wed Jan 16, 2002 11:38 am
by Adrian Kuegel
The input can be like this:
100

10 10 10
60 10

10 10 60
(values like sample input)

Posted: Thu Jan 17, 2002 7:32 pm
by suman
Then how can I understand the input finished? Moreover, are the Angles within the limit 180 to -180 ?
Thanks in advance.


- Suman

Posted: Fri Jan 18, 2002 1:01 pm
by Adrian Kuegel
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.

Why WA for 428?

Posted: Wed Sep 10, 2003 2:34 pm
by boatfish
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]

428 - Swamp County Roofs

Posted: Fri Oct 26, 2007 3:15 am
by MrMDRogers
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

Re: 428, WA...

Posted: Tue May 15, 2012 5:03 am
by brianfry713
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

Re: 428 - Swamp County Roofs

Posted: Thu Aug 04, 2016 10:27 am
by metaphysis
The input format is not so friendly.