Uva 12004 - Bubble Sort Solution

Problem LInk
Uva 12004 - Bubble Sort Solution
#include <cstdio>
using namespace std;
int main(){
    int t,n;
    scanf("%d",&t);
    for(int tc = 1;tc <= t;++tc){
        scanf("%d",&n);
        long long ans = (long long)n * (n-1);
        printf("Case %d: ",tc);
        if(ans % 4 == 0) printf("%lld\n",ans / 4);
        else printf("%lld/2\n",ans / 2);
    }
    return 0;
}

No comments

Theme images by enjoynz. Powered by Blogger.