80分蒟蒻求救
查看原帖
80分蒟蒻求救
921253
yjx412楼主2024/7/22 20:18
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long x;
	char c[10];
	cin>>x>>c[1]>>c[2]>>c[3]>>c[4]>>c[5];
	if(c[2]=='=')
	{
		if(c[4]=='K')
		{
			cout<<fixed<<setprecision(6)<<x/1024.0;
		}
		else if(c[4]=='M')
		{
			cout<<fixed<<setprecision(6)<<x/1048576.0;
		}
		else if(c[4]=='G')
		{
			cout<<fixed<<setprecision(6)<<x/1073741824.0;
		}
		else
		{
			cout<<x;
		}
	}
	else
	{
		if(c[1]=='K')
		{
			if(c[5]=='M')
			{
				cout<<fixed<<setprecision(6)<<x/1024.0;
			}
			else if(c[5]=='G')
			{
				cout<<fixed<<setprecision(6)<<x/1048576.0;
			}
			else if(c[5]=='B')
			{
				cout<<fixed<<setprecision(6)<<x*1024.0;
			}
			else
			{
				cout<<fixed<<setprecision(6)<<x;
			}
		}
		if(c[1]=='M')
		{
			if(c[5]=='G')
			{
				cout<<fixed<<setprecision(6)<<x/1024.0;
			}
			else if(c[5]=='K')
			{
				cout<<fixed<<setprecision(6)<<x*1024.0;
			}
			else if(c[5]=='B')
			{
				cout<<fixed<<setprecision(6)<<x*1073741824.0;
			}
			else
			{
				cout<<fixed<<setprecision(6)<<x;
			}
		}
		if(c[1]=='G')
		{
			if(c[5]=='M')
			{
				cout<<fixed<<setprecision(6)<<x*1024.0;
			}
			else if(c[5]=='K')
			{
				cout<<fixed<<setprecision(6)<<x/1048576.0;
			}
			else if(c[5]=='B')
			{
				cout<<fixed<<setprecision(6)<<x*1024.0;
			}
			else
			{
				cout<<fixed<<setprecision(6)<<x;
			}
		}
	}
	return 0;
}
2024/7/22 20:18
加载中...