Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #pragma comment(linker, "/stack:16777216")
- #include <string>
- #include <vector>
- #include <map>
- #include <list>
- #include <iterator>
- #include <set>
- #include <queue>
- #include <iostream>
- #include <sstream>
- #include <stack>
- #include <deque>
- #include <cmath>
- #include <memory.h>
- #include <cstdlib>
- #include <cstdio>
- #include <cctype>
- #include <algorithm>
- #include <utility>
- #include <fstream>
- #include <time.h>
- using namespace std;
- #define FOR(i, a, b) for(int i = (a); i < (b); ++i)
- #define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
- #define REP(i, N) FOR(i, 0, N)
- #define RREP(i, N) RFOR(i, N, 0)
- #define FILL(A,value) memset(A,value,sizeof(A))
- #define ALL(V) V.begin(), V.end()
- #define SZ(V) (int)V.size()
- #define PB push_back
- #define MP make_pair
- #define y0 gfdssdfer
- #define y1 wetgwervbwqr
- typedef long long Int;
- const int MAX = 2007;
- const int MOD = 1000000007;
- const int INF = 1000000000;
- int main()
- {
- freopen("in.txt" , "r" , stdin);
- // freopen("out.txt" , "w" , stdout);
- int t;
- cin >> t;
- FOR(ttt,0,t)
- {
- int A = 0;
- int B = 2 * INF;
- int N;
- scanf("%d" , &N);
- for(int i = 2; i * i <= 2 * N; ++i)
- {
- if ((2 * N) % i == 0)
- {
- int y = i;
- int x = (2 * N) / i;
- if ((x + y) % 2 == 1)
- {
- int b = (x + y - 1) / 2;
- int a = (x - b);
- if (a >= 0 && b >= 0)
- {
- if (b - a < B - A)
- {
- A = a;
- B = b;
- }
- }
- }
- }
- }
- if (B == 2 * INF)
- {
- printf("IMPOSSIBLE\n");
- }
- else
- {
- printf("%d = ", N);
- FOR(i,A,B)
- {
- printf("%d + ", i);
- }
- printf("%d\n", B);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement