UVa 12114 - Bachelor Arithmetic Solution

#include <iostream>
#include <cmath>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    int b,s;
    int cs=1;
    while(cin>>b>>s&&b){
        cout<<"Case "<<cs++<<": ";
        if(b==1){
            cout<<":-\\"<<endl;
            continue;
        }
        double pre,pos;
        pre=min(1.0,(double)s/b),pos=min(1.0,(double)(s-1)/(b-1));
        if(pre>pos)
            cout<<":-("<<endl;
        else if(pre==pos)
            cout<<":-|"<<endl;
        else
            cout<<":-)"<<endl;
    }
}

Comments