#include <iostream>
#include <algorithm>
#include <cstdio>
void result( const int * b) {
double result = ( double ) b[ 0 ] + ( 13.0 * ( double ) b[ 1 ] / ( double ) b[ 2 ] ) + ( double ) b[ 3 ] + ( 12.0 * ( double ) b[ 4 ] ) - ( double ) b[ 5 ] - 11.0 + ( ( double ) b[ 6 ] * ( double ) b[ 7 ] / ( double ) b[ 8 ] ) - 10.0 ;
if ( result == 66.0 ) {
printf ( "%d + (13 * %d / %d) + %d + (12 * %d) - %d - 11 + (%d * %d / %d) - 10 = %d\n " , b[ 0 ] , b[ 1 ] , b[ 2 ] , b[ 3 ] , b[ 4 ] , b[ 5 ] , b[ 6 ] , b[ 7 ] , b[ 8 ] , ( int ) result) ;
}
}
void calc( ) {
int b[ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 } ;
std:: sort ( b, b + sizeof ( b) / sizeof ( int ) ) ;
do {
result( b) ;
} while ( std:: next_permutation ( b, b + sizeof ( b) / sizeof ( int ) ) ) ;
}
int main( int argc, char * argv[ ] )
{
calc( ) ;
return 0 ;
}
CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGNzdGRpbz4KCnZvaWQgcmVzdWx0KGNvbnN0IGludCAqYikgewoJZG91YmxlIHJlc3VsdCA9IChkb3VibGUpYlswXSArICgxMy4wICogKGRvdWJsZSliWzFdIC8gKGRvdWJsZSliWzJdKSArIChkb3VibGUpYlszXSArICgxMi4wICogKGRvdWJsZSliWzRdKSAtIChkb3VibGUpYls1XSAtIDExLjAgKyAoKGRvdWJsZSliWzZdICogKGRvdWJsZSliWzddIC8gKGRvdWJsZSliWzhdKSAtIDEwLjA7CgoJaWYgKHJlc3VsdCA9PSA2Ni4wKSB7CgkJcHJpbnRmKCIlZCArICgxMyAqICVkIC8gJWQpICsgJWQgKyAoMTIgKiAlZCkgLSAlZCAtIDExICsgKCVkICogJWQgLyAlZCkgLSAxMCA9ICVkXG4iLCBiWzBdLCBiWzFdLCBiWzJdLCBiWzNdLCBiWzRdLCBiWzVdLCBiWzZdLCBiWzddLCBiWzhdLCAoaW50KXJlc3VsdCk7Cgl9Cn0KCnZvaWQgY2FsYygpIHsKCWludCBiW10gPSB7IDEsIDIsIDMsIDQsIDUsIDYsIDcgfTsKCglzdGQ6OnNvcnQoYiwgYiArIHNpemVvZihiKSAvIHNpemVvZihpbnQpKTsKCglkbyB7CgkJcmVzdWx0KGIpOwoJfSB3aGlsZSAoc3RkOjpuZXh0X3Blcm11dGF0aW9uKGIsIGIgKyBzaXplb2YoYikgLyBzaXplb2YoaW50KSkpOwp9CgoKCmludCBtYWluKGludCBhcmdjLCBjaGFyKiBhcmd2W10pCnsKCWNhbGMoKTsKCXJldHVybiAwOwp9Cg==