wenbao与cf010101001010101
小垃圾代码
1 #include <bits/stdc++.h> 2 using namespace std; 3 #define ll long long 4 ll a, b, c, d, x, ax, dx, flag = 0, num = 0; 5 int main(){ 6 cin>>a>>b>>c>>d; 7 // cout<<num<<endl; 8 if( a == 0 && d == 0&&c==0&&b==0 ) { cout <<0 <<endl; return 0; } 9 for( int i = 1; ; i ++ ){ 10 x = i * ( i - 1 ) / 2; 11 // cout<<x<<endl; 12 if( x == a ) ax = i, num ++; 13 if( x == d ) dx = i, num ++; 14 if( num == 2 ) {flag=1;break; } 15 if( x > max( a, d ) ) break; 16 } 17 // cout<<num<<endl; 18 if( ! flag ) cout<<"Impossible"<<endl; 19 else{ 20 if( a == 0 &&c==0&&b==0 ) ax = 0; 21 if( d == 0 &&c==0&&b==0) dx = 0; 22 // cout << ax << " " << dx << endl; 23 if( b + c == ax * dx ){ 24 num = ax + dx; 25 while( num -- ){ 26 if( b >= dx ) { cout<<0; b -= dx; ax --; } 27 else { cout<< 1; dx --; } 28 } 29 } 30 31 else cout <<"Impossible" <<endl; 32 } 33 }
只有不断学习才能进步!