#include <stdio.h>
int main(void)
{
int a[9],b[9];
char k[9]={'+','+','+','+','+','+','+','+','+'};
int i,bc,next,ans,ans_cnt = 0;
while(ans_cnt < 10 && k[8] == '+')
{
//初期化
bc = 1;
next = 1;
for(i = 0; i < 9; i++)
{
a[i] = i+1;
b[i] = 1;
}
//減算&乗算
for(i = 1; i < 9; i++)
{
switch(k[i-1]){
case '-':
a[i] *= -1;
case '+':
bc++;
default:
b[bc-1] *= a[i];
break;
}
}
//加算
ans = b[0];
for(i = 1; i < bc; i++)
ans += b[i];
//答え合わせ
if(ans==100){
ans_cnt++;
for(i = 0; i < 8; i++)
}
//ずらす
for(i = 0; next; i++)
switch(k[i]){
case '+':
k[i] = '-';
next = 0;
break;
case '-':
k[i] = '*';
next = 0;
break;
case '*':
k[i] = '+';
break;
}
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgbWFpbih2b2lkKQp7CiAgICBpbnQgYVs5XSxiWzldOwogICAgY2hhciBrWzldPXsnKycsJysnLCcrJywnKycsJysnLCcrJywnKycsJysnLCcrJ307CiAgICBpbnQgaSxiYyxuZXh0LGFucyxhbnNfY250ID0gMDsKCiAgICB3aGlsZShhbnNfY250IDwgMTAgJiYga1s4XSA9PSAnKycpCiAgICB7CiAgICAgICAgLy/liJ3mnJ/ljJYKICAgICAgICBiYyA9IDE7CiAgICAgICAgbmV4dCA9IDE7CgogICAgICAgIGZvcihpID0gMDsgaSA8IDk7IGkrKykKICAgICAgICB7CiAgICAgICAgICAgIGFbaV0gPSBpKzE7CiAgICAgICAgICAgIGJbaV0gPSAxOwogICAgICAgIH0KCiAgICAgICAgLy/muJvnrpfvvIbkuZfnrpcKICAgICAgICBmb3IoaSA9IDE7IGkgPCA5OyBpKyspCiAgICAgICAgewogICAgICAgICAgICBzd2l0Y2goa1tpLTFdKXsKICAgICAgICAgICAgY2FzZSAnLSc6CiAgICAgICAgICAgICAgICBhW2ldICo9IC0xOwogICAgICAgICAgICBjYXNlICcrJzoKICAgICAgICAgICAgICAgIGJjKys7CiAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICBiW2JjLTFdICo9IGFbaV07CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICAvL+WKoOeulwogICAgICAgIGFucyA9IGJbMF07CiAgICAgICAgZm9yKGkgPSAxOyBpIDwgYmM7IGkrKykKICAgICAgICAgICAgYW5zICs9IGJbaV07CgogICAgICAgIC8v562U44GI5ZCI44KP44GbCiAgICAgICAgaWYoYW5zPT0xMDApewogICAgICAgICAgICBhbnNfY250Kys7CiAgICAgICAgICAgIHByaW50ZigiJWTlgIvnm67jga7nrZTjgYg6IixhbnNfY250KTsKICAgICAgICAgICAgZm9yKGkgPSAwOyBpIDwgODsgaSsrKQogICAgICAgICAgICAgICAgcHJpbnRmKCIlZCVjIixpKzEsa1tpXSk7CiAgICAgICAgICAgIHByaW50ZigiJWRcbiIsOSk7CiAgICAgICAgfQoKICAgICAgICAvL+OBmuOCieOBmQogICAgICAgIGZvcihpID0gMDsgbmV4dDsgaSsrKQogICAgICAgICAgICBzd2l0Y2goa1tpXSl7CiAgICAgICAgICAgIGNhc2UgJysnOgogICAgICAgICAgICAgICAga1tpXSA9ICctJzsKICAgICAgICAgICAgICAgIG5leHQgPSAwOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgJy0nOgogICAgICAgICAgICAgICAga1tpXSA9ICcqJzsKICAgICAgICAgICAgICAgIG5leHQgPSAwOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgJyonOgogICAgICAgICAgICAgICAga1tpXSA9ICcrJzsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgIAogICAgICAgICAgICB9CiAgICB9CgogICAgcmV0dXJuIDA7Cn0=