74 条题解
-
0沉江底 LV 9 @ 2017-06-17 17:01:53
代码巨丑无比,唉,模拟题就是应该思路清晰,不要为了快,否则出了问题找起来超级麻烦,还不一定有慢慢写写的快,emmmmmm,这次就是血的教训。。。55555555555555555,还有一点就是5-8位和1-4位可以执行同一个函数。。
#include <iostream> #include <cstring> using namespace std; char num[50]; char zheng[50]; void read(char* wan,int flag) { if(wan[0]!='0') { cout<<wan[0]<<'Q'; flag=1; } if(wan[1]!='0') { if(wan[0]=='0'&&flag) { cout<<wan[0]; } cout<<wan[1]<<'B'; //flag=1; } if(wan[2]!='0') { if(wan[1]=='0'&&flag) cout<<wan[1]; cout<<wan[2]<<'S'; } if(wan[3]!='0'&&wan[2]=='0'&&flag) { cout<<wan[2]<<wan[3]; } if(wan[3]!='0'&&wan[2]=='0'&&!flag) { cout<<wan[3]; } if(wan[3]!='0'&&wan[2]!='0') { //if(wan[1]=='0') //cout<<wan[1]; cout<<wan[3]; } return; } int main(void) { int count1=0,count2=0,count3=0; int length=0; char wan[5]; char wan2[5]; char wan1[5]; for(int i=0;i<5;i++) { wan[i]='0'; wan1[i]='0'; wan2[i]='0'; } for(int i=0;i<50;i++) { zheng[i]='\0'; } cin>>num; //sprintf(num,"%llf",m); //cout<<num<<endl; //cout<<strlen(num)<<endl; //cout<<"*****"<<endl; length=strlen(num); int flag3=0; for(int i=0;i<length;i++) { if(num[i]=='.') { flag3=1; count3=i; } } if(num[0]=='-') { cout<<'F'; count1++; } else if(num[0]=='+') { count1++; } int flag=0; for(int i=count1;i<length;i++) { if(num[i]=='.') { break; } if(num[i]!='0') { flag=1; } if(flag) { zheng[count2]=num[i]; count2++; } } //cout<<zheng<<"********"<<endl; //cout<<"*********"<<endl; int ptr=0; //cout<<count2<<endl; //Y if(count2==9) { cout<<zheng[0]<<'Y'; ptr++; } //W if(count2>4) { int index=count2-4-ptr; for(int i=0;i<index;i++) { wan[3-i]=zheng[count2-1-4-i]; } read(wan,ptr); if(wan[1]!='0'||wan[0]!='0'||wan[2]!='0'||wan[3]!='0') cout<<'W'; for(int i=0;i<4;i++) { wan2[3-i]=zheng[count2-1-i]; } read(wan2,1); } if(count2<=4) { for(int i=0;i<count2;i++) { wan1[3-i]=zheng[count2-1-i]; } read(wan1,0); } if(count2==0) { cout<<'0'; } //cout<<"**********"<<endl; //cout<<length<<endl; if(flag3&&!((num[length]=='\0')&&num[length-1]=='.')) { cout<<'D'; for(int i=count3+1;i<length;i++) { cout<<num[i]; } } }
-
02016-09-15 20:35:50@
QaQ这辈子最讨厌模拟题了
```c++
#include <iostream>
using namespace std;void op(string s)
{
int i, l;for(i = 0, l = s.size();i < l && s[i] == '0';i ++)
;//cout << endl << s << ' ' << l << ' ' << i << endl;
/*if(s[0] == '0' && s[l - 1] != '0')
cout << '0';
if(i == l - 1)
{
if(s[i] != '0')
cout << s[i];
cout<<"RETY";
return;
}*/
if(s[0] == '0' && (i < l && s[i] != '0'))
cout << '0';
if(i >= l - 1)
{
if(i != l)
cout << s[i];
return;
}if(l - i >= 9)
{
op(s.substr(i, 1 + (l - i > 9)));
cout << 'Y';
op(s.substr(i + 1 + (l - i > 9), l - i - 1));
}
else if(l - i >= 5)
{
op(s.substr(i, l - i - 4));
cout << 'W';
op(s.substr(l - 4, 4));
}
else
{
cout << s[i];
switch(l - i)
{
case 4:
cout << 'Q';
break;
case 3:
cout << 'B';
break;
case 2:
cout << 'S';
break;
default:
break;
}
op(s.substr(i + 1, l - i - 1));
}return;
}int main()
{
string s;
int i, j, l;cin >> s;
if(s[0] == '-')
cout << 'F';
for(i = (s[0] == '+' || s[0] == '-'), l = s.size();i < l && s[i] == '0';i ++)
;
for(j = 0;j < l;j ++)
if(s[j] == '.')
break;if(i == l || s[i] == '.')
cout << '0';
else
op(s.substr(i, j - i + (s[j] != '.')));if(s[j] == '.' && j != l - 1)
{
cout << 'D';
for(j ++;j < l;j ++)
cout << s[j];
}
cout << endl;return 0;
}
``` -
02016-08-13 16:09:59@
一大堆很容易把自己都绕晕啊
Pascal Code
var a,zc,xc,c4:string; n,nz,nx,d,i:integer; procedure say04(var y:string); begin if y[4]='0' then exit else write(y[4]); end; procedure say03(var y:string); begin if y[3]='0' then if y[4]='0' then exit else write('0',y[4]) else begin write(y[3],'S'); say04(y); end; end; procedure say02(var y:string); begin if y[2]='0' then if y[3]='0' then if y[4]='0' then exit else write('0',y[4]) else begin write('0',y[3],'S'); say04(y); end else begin write(y[2],'B'); say03(y); end; end; procedure say4(var y:string;w:integer); begin case w of 4:begin if y[1]='0' then if y[2]='0' then if y[3]='0' then if y[4]='0' then exit else write('0',y[4]) else begin write('0',y[3],'S'); say04(y); end else begin write('0',y[2],'B'); say03(y); end else begin write(y[1],'Q'); say02(y); end; end; 3:begin write(y[1],'B'); if y[2]='0' then if y[3]='0' then exit else write('0') else write(y[2],'S'); write(y[3]); end; 2:begin write(y[1],'S'); if y[2]='0' then exit else write(y[2]); end; 1:write(y[1]); end; end; begin read(a); if a[1]='-' then begin write('F'); delete(a,1,1); end else if a[1]='+' then delete(a,1,1); while (a[1]='0')and(length(a)<>1) do delete(a,1,1); n:=length(a); if pos('.',a)<>0 then begin zc:=copy(a,1,pos('.',a)-1); xc:=copy(a,pos('.',a)+1,n-pos('.',a)); nz:=length(zc); nx:=length(xc); end else begin zc:=a; nz:=n; end; if (nz/4)<>(nz div 4) then d:=nz div 4+1 else d:=nz div 4; for i:=1 to d do begin if i=1 then begin if nz mod 4<>0 then begin c4:=copy(zc,1,nz mod 4); say4(c4,nz mod 4); end else begin c4:=copy(zc,1,4); say4(c4,4); end; if nz mod 4<>0 then delete(zc,1,nz mod 4) else delete(zc,1,4); end else begin c4:=copy(zc,1,4); say4(c4,4); delete(zc,1,4); end; if d=3 then begin if i=1 then write('Y'); if(i=2)and(c4='0000')and(zc[nz-4]<>'0') then write('0'); if (i=2)and(c4<>'0000') then write('W'); end; if d=2 then if i=1 then write('W'); end; if pos('.',a)<>0 then if pos('.',a)=1 then write('0D',xc) else if nx<>0 then write('D',xc); end.
-
02016-03-29 21:47:26@
program _1230sayshu;
var a,zc,xc,c4:string;
n,nz,nx,d,i,kk,nkk:integer;
procedure say04(var y:string);
begin
if y[4]='0' then exit
else write(y[4]);
end;procedure say03(var y:string);
begin
if y[3]='0' then
if y[4]='0' then exit
else write('0',y[4])
else begin
write(y[3],'S');
say04(y);
end;
end;procedure say02(var y:string);
begin
if y[2]='0' then
if y[3]='0' then
if y[4]='0' then exit
else write('0',y[4])
else begin
write('0',y[3],'S');
say04(y);
end
else begin
write(y[2],'B');
say03(y);
end;
end;procedure say4(var y:string;w:integer);
begin
case w of
4: begin
if y[1]='0' then
if y[2]='0' then
if y[3]='0' then
if y[4]='0' then exit
else write('0',y[4])
else begin
write('0',y[3],'S');
say04(y);
end
else begin
write('0',y[2],'B');
say03(y);
end
else begin
write(y[1],'Q');
say02(y);
end;
end;
3: begin
write(y[1],'B');
if y[2]='0' then
if y[3]='0' then exit
else write('0')
else write(y[2],'S');
write(y[3]);
end;
2: begin
write(y[1],'S');
if y[2]='0' then exit
else write(y[2]);
end;
1: write(y[1]);
end;
end;begin
read(a);
if a[1]='-' then
begin
write('F');
delete(a,1,1);
end
else if a[1]='+' then delete(a,1,1);
while (a[1]='0')and(length(a)<>1) do
delete(a,1,1);
n:=length(a);
if pos('.',a)<>0 then
begin
zc:=copy(a,1,pos('.',a)-1);
xc:=copy(a,pos('.',a)+1,n-pos('.',a));
nz:=length(zc);
nx:=length(xc);
end
else
begin
zc:=a;
nz:=n;
end;
if nz/4<>nz div 4 then d:=nz div 4+1
else d:=nz div 4;
for i:=1 to d do
begin
if i=1 then
begin
if nz mod 4<>0 then
begin c4:=copy(zc,1,nz mod 4);say4(c4,nz mod 4);end
else begin c4:=copy(zc,1,4);say4(c4,4);end;
if nz mod 4<>0 then delete(zc,1,nz mod 4)
else delete(zc,1,4);
end
else
begin
c4:=copy(zc,1,4);
say4(c4,4);
delete(zc,1,4);
end;
if d=3 then
begin
if i=1 then write('Y');
if(i=2)and(c4='0000')and(zc[nz-4]<>'0') then write('0');
if (i=2)and(c4<>'0000') then write('W');
end;
if d=2 then
if i=1 then write('W');
end;
if pos('.',a)<>0 then
if pos('.',a)=1 then write('0D',xc)
else if nx<>0 then write('D',xc);
end. -
02014-07-05 23:32:08@
program _1230sayshu;
var a,zc,xc,c4:string;
n,nz,nx,d,i,kk,nkk:integer;
procedure say04(var y:string);
begin
if y[4]='0' then exit
else write(y[4]);
end;procedure say03(var y:string);
begin
if y[3]='0' then
if y[4]='0' then exit
else write('0',y[4])
else begin
write(y[3],'S');
say04(y);
end;
end;procedure say02(var y:string);
begin
if y[2]='0' then
if y[3]='0' then
if y[4]='0' then exit
else write('0',y[4])
else begin
write('0',y[3],'S');
say04(y);
end
else begin
write(y[2],'B');
say03(y);
end;
end;procedure say4(var y:string;w:integer);
begin
case w of
4: begin
if y[1]='0' then
if y[2]='0' then
if y[3]='0' then
if y[4]='0' then exit
else write('0',y[4])
else begin
write('0',y[3],'S');
say04(y);
end
else begin
write('0',y[2],'B');
say03(y);
end
else begin
write(y[1],'Q');
say02(y);
end;
end;
3: begin
write(y[1],'B');
if y[2]='0' then
if y[3]='0' then exit
else write('0')
else write(y[2],'S');
write(y[3]);
end;
2: begin
write(y[1],'S');
if y[2]='0' then exit
else write(y[2]);
end;
1: write(y[1]);
end;
end;begin
read(a);
if a[1]='-' then
begin
write('F');
delete(a,1,1);
end
else if a[1]='+' then delete(a,1,1);
while (a[1]='0')and(length(a)<>1) do
delete(a,1,1);
n:=length(a);
if pos('.',a)<>0 then
begin
zc:=copy(a,1,pos('.',a)-1);
xc:=copy(a,pos('.',a)+1,n-pos('.',a));
nz:=length(zc);
nx:=length(xc);
end
else
begin
zc:=a;
nz:=n;
end;
if nz/4<>nz div 4 then d:=nz div 4+1
else d:=nz div 4;
for i:=1 to d do
begin
if i=1 then
begin
if nz mod 4<>0 then
begin c4:=copy(zc,1,nz mod 4);say4(c4,nz mod 4);end
else begin c4:=copy(zc,1,4);say4(c4,4);end;
if nz mod 4<>0 then delete(zc,1,nz mod 4)
else delete(zc,1,4);
end
else
begin
c4:=copy(zc,1,4);
say4(c4,4);
delete(zc,1,4);
end;
if d=3 then
begin
if i=1 then write('Y');
if(i=2)and(c4='0000')and(zc[nz-4]<>'0') then write('0');
if (i=2)and(c4<>'0000') then write('W');
end;
if d=2 then
if i=1 then write('W');
end;
if pos('.',a)<>0 then
if pos('.',a)=1 then write('0D',xc)
else if nx<>0 then write('D',xc);
end. -
02014-03-20 19:16:43@
const a:array[2..10]of char=('S','B','Q','W','S','B','Q','Y','S');
var s:string;j,ss,i,jj,sss:longint;
begin
readln(s);
if s[1]='-' then begin i:=2;write('F');end else i:=1;
if s[1]='+' then i:=2;
if s[1]='.' then write('0');
while(s[i]='0')and(s[i+1]<>'.')and(i<length(s))do inc(i);
j:=i;ss:=0;
while(s[j]<>'.')and(j<=length(s))do begin inc(j);inc(ss);end;
while(s[i]<>'.')and(i<=length(s))do
begin
if s[i]='0' then
begin
write(0);
while s[i]='0' do begin inc(i);dec(ss);end;
end
else
begin
if ss<>1 then
begin
write(s[i],a[ss]);dec(ss);jj:=i+1;sss:=0;
if(ss=1)and(s[i+1]='0')then begin inc(i,2);break;end;
end
else write(s[i]);
inc(i);
end;
end;
if i>=length(s) then halt;
write('D');inc(i);
while i<=length(s) do begin write(s[i]);inc(i);end;
end. -
02013-10-30 21:54:37@
var a,i,j,k,l,m:longint;
ans,n:string;
b:array[1..11] of string=('','S','B','Q','W','','','','Y','','');
bo:boolean;
nn:double;
begin
readln(n);
If n[1]='+' then Delete(N,1,1);
if n[1]='-' then begin ans:='F';delete(n,1,1);end;
if n[length(n)]='.' then delete(n,length(n),1);
If n[1]='.' then n:='0'+n;
while (n[1]='0')and(length(n)>1)and(n[2]<>'.') do delete(n,1,1);
repeat i:=pos('.',n)-1;
if i=-1 then i:=length(n);
if b[i]<>'' then
begin
ans:=ans+n[1]+b[i];delete(n,1,1);
end
else
begin
for j:=i downto 1 do
if b[j]<>'' then break;
l:=i-j+1;
ans:=ans+n[1]+b[l];
bo:=false;
for k:=2 to j do
if n[k]<>'0' then begin bo:=true;break;end;
if not(bo) then ans:=ans+b[j];
delete(n,1,1);
end;
bo:=false;
i:=pos('.',n)-1;
if i=-1 then i:=length(n);
for j:=1 to i do
if n[j]<>'0' then begin bo:=true;break;end;
if (bo)and(n[1]='0') then ans:=ans+'0';
while (n[1]='0')and(length(n)>1) do delete(n,1,1);
if (n[1]='.')or(n='')or(n='0') then break;
until false;
if n[1]='.' then
begin
ans:=ans+'D';
for i:=2 to length(n) do
ans:=ans+n[i];
end;
writeln(ans);
end. -
02012-08-04 21:59:06@
别以为题目容易,其实很考验人的耐心和细心,
注意数据会出得很极端
(测试数据仅供参考)
输入1:123456789
输出1:1Y2Q3B4S5W6Q7B8S9输入2:1234.56789
输出2:1Q2B3S4D56789输入3:+123456789.01234
输出3:1Y2Q3B4S5W6Q7B8S9D01234输入4:-0000123456.0001200
输出4:F1S2W3Q4B5S6D0001200输入5:-003010.
输出5:F3Q01S输入6:+00101010101.00
输出6:1Y01B01W01B01D00输入7:000000111111111
输出7:1Y1Q1B1S1W1Q1B1S1输入8:.012
输出8:0D012输入9:00000000000000
输出9:0输入10:+900000001.012345600001234560000123456000012345600
输出10:9Y01D012345600001234560000123456000012345600鄙人在一个多小时的艰难困苦拼命刷新AC率下,终于终于...终于AC啦!!
#01: Accepted (28ms, 580KB)
#02: Accepted (39ms, 580KB)
#03: Accepted (0ms, 580KB)
#04: Accepted (0ms, 580KB)
#05: Accepted (0ms, 580KB)
#06: Accepted (0ms, 580KB)
#07: Accepted (0ms, 580KB)
#08: Accepted (0ms, 580KB)
#09: Accepted (0ms, 580KB)
#10: Accepted (0ms, 580KB) -
02010-07-07 19:15:37@
program fadf;
var i,j,n,m,k,len,p:longint; code:integer;
s,s1,a,a1:string;
b:array[1..15] of char;
begin
for i:=1 to 15 do b[i]:='p';
b[2]:='S'; b[3]:='B'; b[4]:='Q'; b[5]:='W';
b[6]:='S'; b[7]:='B'; b[8]:='Q'; b[9]:='Y';
b[10]:='S'; b[11]:='B';
readln(s);
if s[1]='+' then delete(s,1,1)
else if s[1]='-' then
begin
delete(s,1,1);
s1:=s1+'F';
end;
p:=pos('.',s); if p=0 then p:=length(s)+1;
a:=copy(s,1,p-1);
while (length(a)>0)and(a[1]='0') do delete(a,1,1);if a='' then s1:=s1+'0'
else
begin
for i:=1 to length(a) do
a1:=a1+a[length(a)-i+1];
a:=a1;
i:=length(a);
while i>0 do
begin
if a[i]'0' then
s1:=s1+a[i]+b[i];
dec(i); j:=0;
while (a[i]='0')and(i>=1) do
begin
if i in [5,9] then
begin
if (a'0') or(a'0') or (a'0') then
s1:=s1+b[i]; end;
dec(i); inc(j);
end;
if (j>0)and(i>=1) then s1:=s1+'0';
end;
end;
if p -
02010-07-03 08:54:11@
交了好多次终于AC了,晕死了……
大家注意了第五组:-003010.
开始没注意“.”,总是错,且不知道错在哪 -
02010-04-11 21:00:57@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0msAC第50道题!!! 纪念一下。。
-
02010-03-18 23:35:20@
真可恶,还有个“+”在。搞死我了
-
02009-11-06 07:45:45@
试试这两个数据:
111010101.01
101011101.01 -
02009-11-02 10:40:53@
一次AC。递归读数。
-
02009-11-01 15:42:05@
谢谢楼下的提醒。
居然有 “.012” 这样的数据。
这种数字的写法我就没见过,更别说考虑到。结果交了N次。。。 -
02009-10-14 19:04:54@
第9个点全是0 应输出0
-
02009-10-08 19:54:21@
虽说只不过是简单的模拟,但是我也交了好几次才AC,模拟最重要的是细节。
现在顿感当初学会读数字的伟大了…… -
02009-10-06 16:58:01@
101010101这种数据巨猥琐啊。。
-
02009-10-06 15:23:55@
第五组数据是什么啊!!!!!!!!!!!!!!!!!!!!!!!!!!??????????????
-
02009-09-05 09:43:24@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms第888个AC 以此纪念...