Wednesday, June 29, 2016

UVa 12342 Tax Calculator

#include <bits/stdc++.h>
#define LL long long
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define REV(i,n) for(int i=n-1;i>=0;i--)
#define pri(a) cout << a << endl;
#define prii(a,b) cout << a << " " << b << endl;
using namespace std;

LL per(LL n, LL x)
{
    LL res = ceil((double)((n*x)/(100*1.0)));
    return res;
}

int main()
{
    int n,T,cs=0;
    scanf("%d", &T);
    while(T--)
    {
        LL tx = 0;
        printf("Case %d: ", ++cs);

        cin>>n;

        if(n>(180000+300000+400000+300000))
        {
            tx += 0+per(300000,10)+per(400000,15)+per(300000,20)+per(n-(180000+300000+400000+300000),25);
        }
        else if(n>(180000+300000+400000))
        {
            tx += 0+per(300000,10)+per(400000,15)+per(n-(180000+300000+400000),20);
        }
        else if(n>(180000+300000))
        {
            tx += 0+per(300000,10)+per(n-(180000+300000),15);
        }
        else if(n>(180000))
        {
            tx += 0+per(n-(180000),10);
        }
        else tx = 0;

        if(tx>0 and tx<2000) tx=2000;

        pri(tx);
    }
    return 0;
}

No comments:

Post a Comment