记录编号 42888 评测结果 AAAAAAAAAA
题目名称 [NOIP 2010冲刺四]报数 最终得分 100
用户昵称 GravatarMakazeu 是否通过 通过
代码语言 C++ 运行时间 0.003 s
提交时间 2012-10-01 23:44:37 内存使用 3.13 MiB
显示代码纯文本
#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;
}