N Queens Puzzle Solved ! Solution
Codechef February Long Challenge 2022 - I
Problem Code : EUREKA
Solution :
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
using namespace std;
void solve()
{
ll n;
cin >> n;
double x = (0.143) * n;
double y = 1;
for (ll i = 0; i < n; i++)
{
y = y * x;
}
ll k = floor(y);
if (y - k < 0.5)
{
cout << k << "\n";
}
else
{
cout << k + 1 << "\n";
}
}
int main()
{
ll t;
cin >> t;
while (t--)
{
solve();
}
}
Comments
Post a Comment