-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBLOPER.cpp
More file actions
50 lines (49 loc) · 712 Bytes
/
BLOPER.cpp
File metadata and controls
50 lines (49 loc) · 712 Bytes
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
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,s,i;
cin>>n>>s;
bool flag=false;
bool check[510]={false};
if(s<0){
flag = true;
s=-1*s;}
int total = n*(n+1)/2;
int half=total-s;
if(half & 1 || total <s)
printf("Impossible\n");
else
{
half>>=1;
if(flag)
half-=1;
for(i=n;i>1;i--)
{
if(half-i >1){
half-=i;
check[i] = true;
}
else if(half - i ==0)
{
half-=i;
check[i] = true;
break;
}
}
if(half)
printf("Impossible\n");
else
{
printf("1");
if(flag)
for(i=2;i<=n;i++)
check[i]?cout<<"+"<<i:cout<<"-"<<i;
else
for(i=2;i<=n;i++)
check[i]?cout<<"-"<<i:cout<<"+"<<i;
cout<<endl;
}
}
return 0;
}