View Code of Problem 96

#include<stdio.h>
#include<math.h>
void main() {
	int n,i=1024,j=1000;
	char str[20];
	while(~scanf("%d%s",&n,str)){
		double s=0; 
		if(n==0) break;
		if(str[0]=='B')
			s=0;
		else if(str[0]=='K')
			s=n*(i-j);
		else if(str[0]=='M')
			s=n*(pow(i,2)-pow(j,2));
		else if(str[0]=='G')
			s=n*(pow(i,3)-pow(j,3));
		else if(str[0]=='T')
			s=n*(pow(i,4)-pow(j,4));
			
		printf("%.0f\n",s);
	}
}

Double click to view unformatted code.


Back to problem 96