ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1823. Ideal Gas

WA 11 Why?
Posted by SerCe 20 Mar 2011 13:00
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <cmath>

using namespace std;

int p=0,n=0,V=0,T=0;
char c;
int a=0,b=0,c1=0,d=0;
double R=8.314;

int main()
{
    for(int i = 0; i < 3; i++)
    {
        cin >> c;
        if(c=='p')
        {
            cin >> c;
            cin >> p;
            a++;
        }
        if(c=='n')
        {
            cin >> c;
            cin >> n;
            b++;
        }
        if(c=='V')
        {
            cin >> c;
            cin >> V;
            c1++;
        }
        if(c=='T')
        {
            cin >> c;
            cin >> T;
            d++;
        }

    }
    if(a==0) cout << "p = " << R*n*T/V;
    if(b==0) cout << "n = " << p*V/(R*T);
    if(c1==0)
    {
        if(p==0 && n==0)
        {
            cout << "undefined";
            return 0;
        }
        if(p==0 || n==0)
        {
            cout << "error";
            return 0;
        }
        cout << "V = " << R*n*T/p;
    }
    if(d==0)
    {
        if(p==0 && n==0)
        {
            cout << "undefined";
            return 0;
        }
        if(p==0 || n==0)
        {
            cout << "error";
            return 0;
        }
        cout << "T = " << p*V/(R*n);
    }
    return 0;
}

Так же было и на самом контесте WA 11, сейчас тоже WA 11, хотя на разборе говорили все тоже самое

Edited by author 20.03.2011 13:07

Edited by author 20.03.2011 13:07
Re: WA 11 Why?
Posted by Michael Plusnin (USU) 10 Apr 2011 15:35
Use printf;
Re: WA 11 Why?
Posted by Lucian Ilea 14 Jul 2011 17:48
Write something like this

printf("n = %0.7Lf",rez);

and be sure that you don't have any cout<<.
I don't know the reason, this was my "mistake" and produced many WA :(


Edited by author 14.07.2011 17:56
Re: WA 11 Why?
Posted by Marin Tiberiu 21 Aug 2012 15:28
You can also write with setprecision. I think you have to output at least 3 decimals but I'm not sure.
Re: WA 11 Why?
Posted by [RISE] Binary_Mind [RAU] 15 Aug 2014 21:45
You must use fixed setprecision at least with 5 decimals:
cout << fixed << setprecision(5);