|
|
Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения | how to explain it??? | Ilya_Malinovsky | 1457. Теплотрасса | 28 авг 2010 17:14 | 1 | I got WA #4 with such code: #include <cstdio> #include <iostream> #include <cmath> using namespace std; int main() { int n; double a, sum = 0.0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%le", &a); sum += a; } printf("%.15e", sum / n); return 0; } WA #5 with such code: #include <cstdio> #include <iostream> #include <cmath> using namespace std; int main() { int n; double a, sum = 0.0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%le", &a); sum += a; } printf("%.7e", sum / n); return 0; } WA #6 with such code: #include <cstdio> #include <iostream> #include <cmath> using namespace std; int main() { int n; double a, sum = 0.0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%le", &a); sum += a; } printf("%.8e", sum / n); return 0; } AC with such code: #include <cstdio> #include <iostream> #include <cmath> using namespace std; int main() { int n; double a, sum = 0.0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%le", &a); sum += a; } printf("%.15e", sum / n); return 0; } But, connecting to the problem statements, "The offset should be printed with at least six digits after decimal point." | Digits after the point C++ | MiR | 1457. Теплотрасса | 28 авг 2010 00:38 | 5 | How to show 6 digits after the point using double/float variable? You can do one of the following ways : 1) fprintf(stdout,"%.6lf ",n) ; or printf("%.6lf",n) ; 2) setprecision( 6 ) ; cout << n ; /* in this way , it won't print out the last zero digits. for instance : if n == 0.777 , it will print out "0.777" in stead of "0.777000" if n == 0.777001 , it will print out exactly 6 digits after the decimal point ( "0.777001" ) */ Edited by author 25.07.2006 15:55 what if i want zero digits? using c++, not c Edited by author 28.08.2010 00:39 cout.precision( 6 ); cout << fixed << variable; | wa#4 | arhats | 1457. Теплотрасса | 19 сен 2009 20:19 | 2 | wa#4 arhats 18 мар 2009 19:48 can you give me some tests???????????? Re: wa#4 luc1kJke_(It-Team) 19 сен 2009 20:19 cout.precision(6); cout<<fixed<<sum; mby u just forgot "fixed"? P.S. that fixed my wa4 | Here my solution | yaho0o0 | 1457. Теплотрасса | 8 апр 2009 12:57 | 3 | #include <iostream> #include <stdio.h> using namespace std; int main() { int i,n,a; double o=0; cin>>n; for(i=1;i<=n;i++) { cin>>a; o+=a; } o/=n; fprintf(stdout,"%.6lf ",o); cout<<endl; return 0; } Edited by author 07.04.2009 21:17 Edited by author 08.04.2009 12:58 | I' ve ac this problem! | Charlie | 1457. Теплотрасса | 26 янв 2009 20:58 | 3 | program ex; var n,m,i:integer; ans:real; begin readln (n); for i:=1 to n do begin read (m); ans:=ans+m; end; ans:=ans/n; writeln (ans:0:6); end. It's not very good to define m as integer. | why WA1?please supply some test cases | Anupam Ghosh,Bengal Engg and Sc Uni,MtechIT,2006-09,India | 1457. Теплотрасса | 7 июл 2008 11:33 | 1 | does the problem require only finding average that i have done still WA1. can please someone give me some test cases?? Edited by author 08.07.2008 11:04 Edited by author 08.07.2008 11:05 | If you wan to AC,please use DOUBLE not FLOAT!!! | Jerry_Killer | 1457. Теплотрасса | 16 дек 2006 10:46 | 1 | |
|
|
|