Advertisement
Kaidul

A

Feb 20th, 2014
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.12 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define MEMSET_INF 127
  6. #define MEMSET_HALF_INF 63
  7. #define stream istringstream
  8. #define rep(i,n) for(__typeof(n) i=0; i<(n); i++)
  9. #define repl(i,n) for(__typeof(n) i=1; i<=(n); i++)
  10. #define FOR(i,a,b) for(__typeof(b) i=(a); i<=(b); i++)
  11. #define INF (1<<30)
  12. #define PI acos(-1.0)
  13. #define pb push_back
  14. #define ppb pop_back
  15. #define all(x) x.begin(),x.end()
  16. #define mem(x,y) memset(x,y,sizeof(x))
  17. #define memsp(x) mem(x,MEMSET_INF)
  18. #define memdp(x) mem(x,-1)
  19. #define memca(x) mem(x,0)
  20. #define eps 1e-9
  21. #define pii pair<int,int>
  22. #define pmp make_pair
  23. #define ft first
  24. #define sd second
  25. #define vi vector<int>
  26. #define vpii vector<pii>
  27. #define si set<int>
  28. #define msi map<string , int >
  29. #define mis map<int , string >
  30. typedef long long i64;
  31. typedef unsigned long long ui64;
  32. /** function **/
  33. #define SDi(x) sf("%d", &x)
  34. #define SDl(x) sf("%lld", &x)
  35. #define SDs(x) sf("%s", x)
  36. #define SD2(x,y) sf("%d%d", &x, &y)
  37. #define SD3(x,y,z) sf("%d%d%d", &x, &y, &z)
  38. #define pf printf
  39. #define print(x) pf("%d ", x)
  40. #define println(x) pf("%d\n", x)
  41. #define sf scanf
  42. #define READ(f) freopen(f, "r", stdin)
  43. #define WRITE(f) freopen(f, "w", stdout)
  44.  
  45. const i64 INF64 = (i64)1E18;
  46.  
  47. template<class T> inline T gcd(T a,T b) {
  48.     if(a<0)return gcd(-a,b);
  49.     if(b<0)return gcd(a,-b);
  50.     return (b==0)?a:gcd(b,a%b);
  51. }
  52. template<class T> inline T lcm(T a,T b) {
  53.     if(a<0)return lcm(-a,b);
  54.     if(b<0)return lcm(a, -b);
  55.     return a*(b/gcd(a,b));
  56. }
  57. template<class T> inline T sqr(T x) {
  58.     return x*x;
  59. }
  60. template<class T> T power(T N,T P) {
  61.     return (P==0)?  1: N*power(N,P-1);
  62. }
  63. template<class T> bool inside(T a,T b,T c) {
  64.     return (b>=a && b<=c);
  65. }
  66. double _dist(double x1,double y1,double x2,double y2) {
  67.     return sqrt(sqr(x1-x2)+sqr(y1-
  68.                                y2));
  69. }
  70. int distsq(int x1,int y1,int x2,int y2) {
  71.     return sqr(x1-x2)+sqr(y1-y2);
  72. }
  73. i64 toInt64(string s) {
  74.     i64 r=0;
  75.     istringstream sin(s);
  76.     sin>>r;
  77.     return r;
  78. }
  79. double Log(i64 N, i64 B) {
  80.     return (log10l(N)) / (log10l(B));
  81. }
  82. string itoa(long long a) {
  83.     if(a==0) return "0";
  84.     string ret;
  85.     for(long long i=a; i>0; i=i/10)
  86.         ret.push_back((i%10)+48);
  87.     reverse(ret.begin(),ret.end());
  88.     return ret;
  89. }
  90. vector< string > token( string a, string b ) {
  91.     const char *q = a.c_str();
  92.     while( count( b.begin(), b.end(), *q ) ) q++;
  93.     vector< string > oot;
  94.     while( *q ) {
  95.         const char *e = q;
  96.         while( *e && !count( b.begin(), b.end(), *e ) )
  97.             e++;
  98.         oot.push_back( string( q, e ) );
  99.         q = e;
  100.         while( count( b.begin(), b.end(), *q ) )
  101.             q++;
  102.     }
  103.     return oot;
  104. }
  105.  
  106. int isvowel(char s) {
  107.     s=tolower(s);
  108.     if(s=='a' or s=='e' or s=='i' or s=='o' or s=='u')
  109.         return 1;
  110.     return 0;
  111. }
  112. int isupper(char s) {
  113.     if(s>='A' and s<='Z') return 1;
  114.     return 0;
  115. }
  116. template<class T> struct Fraction {
  117.     T a,b;
  118.     Fraction(T a=0,T b=1);
  119.     string
  120.     toString();
  121. };//NOTES:Fraction
  122. template<class T> Fraction<T>::Fraction(T a,T b) {
  123.     T d=gcd(a,b);
  124.     a/=d;
  125.     b/=d;
  126.     if (b<0) a=-a, b=-b;
  127.     this->a=a;
  128.     this->b=b;
  129. }
  130. template<class T> string Fraction<T>::toString() {
  131.     ostringstream
  132.     sout;
  133.     sout<<a<<"/"<<b;
  134.     return sout.str();
  135. }
  136. template<class T> Fraction<T> operator+(Fraction<T> p,Fraction<T> q) {
  137.     return
  138.         Fraction<T>(p.a*q.b+q.a*p.b,p.b*q.b);
  139. }
  140. template<class T> Fraction<T> operator-(Fraction<T> p,Fraction<T> q) {
  141.     return
  142.         Fraction<T>(p.a*q.b-q.a*p.b,p.b*q.b);
  143. }
  144. template<class T> Fraction<T> operator*(Fraction<T> p,Fraction<T> q) {
  145.     return
  146.         Fraction<T>(p.a*q.a,p.b*q.b);
  147. }
  148. template<class T> Fraction<T> operator/(Fraction<T> p,Fraction<T> q) {
  149.     return
  150.         Fraction<T>(p.a*q.b,p.b*q.a);
  151. }
  152.  
  153. /** BitMask **/
  154. int Set(int N, int pos) {
  155.     return N = N | (1 << pos);
  156. }
  157. int Reset(int N,int pos) {
  158.     return N = N & ~(1 << pos);
  159. }
  160. int Check(int N, int pos) {
  161.     return (N & (1 << pos));
  162. }
  163. int toggle(int N, int pos) {
  164.     if( Check(N, pos) )
  165.         return N = Reset(N, pos);
  166.     return N = Set(N, pos);
  167. }
  168.  
  169. const i64 INFFF = 1e16;
  170.  
  171. int main(void) {
  172.     int tcase, caseNo = 0;
  173. #ifndef ONLINE_JUDGE
  174.     READ("input.txt");
  175. #endif
  176.     char in[500];
  177.     cin >> in;
  178.     int a, b, c;
  179.     a = b = c = 0;
  180.     char ch = in[a];
  181.     while(ch != '+') {
  182.         ++a;
  183.         ch = in[a];
  184.     }
  185.     int i = a + 1;
  186.     while(ch != '=') {
  187.         ++b;
  188.         ++i;
  189.         ch = in[i];
  190.     }
  191.     ++i;
  192.     while(ch != '\0') {
  193.         ++c;
  194.         ++i;
  195.         ch = in[i];
  196.     }
  197.     if(a + b == c) {
  198.         cout << in << endl;
  199.     } else if(a + b == c - 2) {
  200.         rep(i, a + 1) cout << "|";
  201.         cout << "+";
  202.         rep(i, b) cout << "|";
  203.         cout << "=";
  204.         rep(i, c - 1) cout << "|";
  205.         cout << endl;
  206.     } else if(a + b == c + 2) {
  207.         rep(i, a - 1) cout << "|";
  208.         cout << "+";
  209.         rep(i, b) cout << "|";
  210.         cout << "=";
  211.         rep(i, c + 1) cout << "|";
  212.         cout << endl;
  213.     }else {
  214.         cout << "Impossible\n";
  215.     }
  216.     return 0;
  217. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement