比赛 20120808 评测结果 AAAAAAAAAA
题目名称 报数 最终得分 100
用户昵称 Makazeu 运行时间 0.003 s
代码语言 C++ 内存使用 0.32 MiB
提交时间 2012-08-08 10:41:13
显示代码纯文本
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
string str,zeng,kid;
int num; bool zero=0;

int main()
{
	freopen("readrule.in","r",stdin);
	freopen("readrule.out","w",stdout);
	cin>>str;
	if(str[0]=='-') {cout<<"F";str=str.substr(1);}
	while(*str.data()=='0') str=str.substr(1);
	//cout<<str<<endl;
	if(str=="") {cout<<"0"<<endl;return 0;}
	if(str[0]=='.') {cout<<"0D"<<str.substr(1)<<endl;return 0;}
	for(unsigned int i=0;i<str.length();i++)
	{
		if(str[i]=='.') {str=str.substr(i);break;}
		zeng.push_back(str[i]);
	}
	if(zeng==str) {str="";}
	//cout<<zeng<<endl;
	int zlen=zeng.length();
	if(zeng.size()>8)
	{
		sscanf(zeng.c_str(),"%d",&num);
		num/=100000000;
		//cout<<num<<endl;
		if(num<10) cout<<num<<"Y";
		else cout<<"1S1Y";
	}
	if(zeng.size()>4)
	{
		sscanf(zeng.c_str(),"%d",&num);
		num%=100000000;
		num/=10000;
		//cout<<num<<endl;
		if(num==0) goto next1;
		if((num/1000)) cout<<num/1000<<"Q";
		else if(zlen>8) {cout<<0;zero=1;}
		num%=1000;
		if(num==0) {cout<<"W";goto next1;}
		if((num/100)) {zero=0;cout<<num/100<<"B";}
		else {if(!zero && zlen>7){cout<<0;zero=1;} }
		num%=100;
		if(num==0) {cout<<"W";goto next1;}
		if((num/10)) {zero=0;cout<<num/10<<'S';}
		else {if(!zero && zlen>6){cout<<0;zero=1;} }
		num%=10;
		if(num==0) {cout<<"W";goto next1;}
		if(num) cout<<num;cout<<"W";
	}
	
	next1:
	sscanf(zeng.c_str(),"%d",&num);
	num%=10000;
	if(num==0) goto next2;
	if((num/1000)) cout<<num/1000<<"Q";
	else if(zlen>4){cout<<0; zero=1;}
	num%=1000;
	if(num==0) goto next2;
	if((num/100)) {zero=0;cout<<num/100<<"B";}
	else {if(!zero && zlen>3){cout<<0;zero=1;}}
	num%=100;
	if(num==0) goto next2;
	if((num/10)) {zero=0;cout<<num/10<<"S";}
	else {if(!zero && zlen>2){cout<<0;zero=1;}}
	num%=10;if(num) cout<<num;
	
	next2:
	if(str.size())
		cout<<"D"<<str.substr(1)<<endl;
	else cout<<endl;
	return 0;
}