-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathICPC_1.cpp
More file actions
71 lines (69 loc) · 1.37 KB
/
ICPC_1.cpp
File metadata and controls
71 lines (69 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
int main()
{
ll test;
cin>>test;
while(test--)
{
double a;
ll n,m;
cin>>n>>m;
if(m<0)
{
cout<<-1<<endl;
continue;
}
if(n==1&&m!=0)
{
cout<<-1<<endl;
continue;
}
// Main formula
a=sqrt(((double)3*m*m*n)/((double)(n/2)*((n/2)+1)*(2*(n/2)+1)));
if(n%2==1)
{
if(m==0)
{
for(ll i=-n/2;i<=n/2;i++)
{
cout<<"0 ";
}
}
else
{
for(ll i=-n/2; i<=n/2; i++)
{
cout<<(float)i*a<<" ";
}
}
}
else
{
if(m==0)
{
for(ll i=-n/2;i<n/2;i++)
{
cout<<"0 ";
}
}
else
{
for(ll i=-n/2;i<0;i++)
{
cout<<(float)i*a<<" ";
}
for(ll i=1;i<=n/2;i++)
{
cout<<(float)i*a<<" ";
}
}
}
cout<<endl;
}
return 0;
}