WA in THREDICE

https://www.codechef.com/viewsolution/49844568
can anyone tell what’s wrong in the code

1 Like

Use std::fixed & std::setprecision(x) to output upto what decimal point is required! (‘x’ is your required precision)
and You unfortunetly missed a corner case, what if the calculated value is less than or equal to 0.

Here is your code with some modification:

//By-Ashutosh Kumar Pat`
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define ll long long
#define mod 1000000007

void solve()
{
   int x, y;
   cin >> x >> y;
   double ans = (double)(6 - (x + y));

   if (ans <= 0)
   {
      std::cout << "0\n";
   }
   else
      cout << fixed << setprecision(10) << ans / 6 << '\n';
}

int main()
{
   ios::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   int t = 1;
   cin >> t;
   while (t--)
      solve();
   return 0;
}`