Wrong answer in "ICM0003"

Please check my code why is it giving WA , even tho it is correct for sample testcases

#include<bits/stdc++.h>
#include <cmath>
using namespace std;

#define ar array
#define ll long long

const int MAX_N = 1e5 + 1;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;




void solve() {
    ll int n,m,x,y,cnt=0,temp,sum=0,i,j,k,l,maxi=0,mini=INF;
    double r,ans;
    string str;
    cin>>n;
    double theta = 180/n;
    double extra_parts,total_area,c,d;
    theta = theta*3.141592653/180;

    extra_parts= (sin(2*theta) * n)/(double)8;

    total_area=  (((cos(theta)/(sin(theta)))*n))/4;
    c= total_area-extra_parts;
 
    r= 1-(double)(c/total_area);;
    // ans = r (1/r + (1-r)/r^2) 
    ans = 1+ (1-r)/r;
    cout << fixed << setprecision(6) << ans<<endl;





}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int tc = 1;
     cin >> tc;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case #" << t  << ": ";
        solve();
    }
}

You have taken n as long long type either change your n to double or you can do type conversion I have made some changes, Here is your accepted solution

2 Likes

Thanks a lot!

when will the ratings come ??

After Long challenge