#include #include #include #include #define LL __int64 using namespace std; LL a[20],cnt,k; map ans; map::iterator it; bool cmp(LL a,LL b) { return a>b; } LL cal(LL sum,LL temp,LL op) { if(op==0) return sum+temp; if(op==1) return sum-temp>0? sum-temp:temp-sum; if(op==2) return sum*temp; if(op==3) return sum/temp; } void dfs(LL x,LL sum) { if(x==cnt) { LL tempsum=sum; while(tempsum) { if(tempsum%10==3) { ans[sum]++; k++; break; } tempsum/=10; } return ; } for(LL i=0;i<4;i++) { if(i==3 && a[x]==0) continue; LL temp=cal(sum,a[x],i); dfs(x+1,temp); } } int main() { char s[100]; LL len,i; while(gets(s)) { if(s[0]=='#') break; ans.clear(); len=strlen(s); LL temp; cnt=temp=0; for(i=0;isecond)) { maxt=it->second; maxans=it->first; if((it->first)>maxans) maxans=it->first; } } printf("%I64d\n",maxans); } else printf("No result\n"); } return 0; }