为啥我MLE!本地没问题。

P1553 数字反转(升级版)

/*cpp #include <iostream> #include <cstdio> #include <algorithm> #include <cmath> using namespace std; int zf; int m; int shu; void dfs(void){ char a = getchar(); if(a == '\n')return ; if(a == '-') zf = 1,a = getchar(); if(a == '.'){ m = 1; return; } if(a == '%'){ m = 2; return; } if(a == '/'){ m = 3; return; } dfs(); if(!shu){ if(a == '0') return; } cout << a;shu = 1; return ; } int kk; void dfs2(void){ char a = getchar(); while(a=='0'&&!kk) a = getchar(); dfs(); if(!shu){ if(a == '0') return; } cout << a;shu = 1; return ; } int main(void){ dfs(); if(zf) cout << "-"; if(!shu) cout << "0"; if(m == 1){ shu = 0; cout << "."; dfs2(); if(!shu) cout << "0"; } if(m == 2){ cout << "%"; } if(m == 3){ cout << "/"; shu = 0; dfs(); if(!shu) cout << "0"; } return 0; } */
by Sparda @ 2019-05-30 17:50:35


本地没问题,但是题目限制了空间,所以会MLE
by gwx123456 @ 2019-05-30 17:51:52


'''cpp #include <iostream> #include <cstdio> #include <algorithm> #include <cmath> using namespace std; int zf; int m; int shu; void dfs(void){ char a = getchar(); if(a == '\n')return ; if(a == '-') zf = 1,a = getchar(); if(a == '.'){ m = 1; return; } if(a == '%'){ m = 2; return; } if(a == '/'){ m = 3; return; } dfs(); if(!shu){ if(a == '0') return; } cout << a;shu = 1; return ; } int kk; void dfs2(void){ char a = getchar(); while(a=='0'&&!kk) a = getchar(); dfs(); if(!shu){ if(a == '0') return; } cout << a;shu = 1; return ; } int main(void){ dfs(); if(zf) cout << "-"; if(!shu) cout << "0"; if(m == 1){ shu = 0; cout << "."; dfs2(); if(!shu) cout << "0"; } if(m == 2){ cout << "%"; } if(m == 3){ cout << "/"; shu = 0; dfs(); if(!shu) cout << "0"; } return 0; } '''
by Sparda @ 2019-05-30 17:53:02


@[gwx123456](/space/show?uid=168385) buzhiyuba
by Sparda @ 2019-05-30 17:53:46


希望更丰富的展现?使用Markdown
by AOTO @ 2019-05-30 17:54:05


wo you meiyou kai shuzu (shouji babuliao hanzi buzhidao weishenme
by Sparda @ 2019-05-30 17:54:47


@[Sparda](/space/show?uid=48850) zhiyu
by gwx123456 @ 2019-05-30 17:55:45


~~~cpp #include <iostream> #include <cstdio> #include <algorithm> #include <cmath> using namespace std; int zf; int m; int shu; void dfs(void){ char a = getchar(); if(a == '\n')return ; if(a == '-') zf = 1,a = getchar(); if(a == '.'){ m = 1; return; } if(a == '%'){ m = 2; return; } if(a == '/'){ m = 3; return; } dfs(); if(!shu){ if(a == '0') return; } cout << a;shu = 1; return ; } int kk; void dfs2(void){ char a = getchar(); while(a=='0'&&!kk) a = getchar(); dfs(); if(!shu){ if(a == '0') return; } cout << a;shu = 1; return ; } int main(void){ dfs(); if(zf) cout << "-"; if(!shu) cout << "0"; if(m == 1){ shu = 0; cout << "."; dfs2(); if(!shu) cout << "0"; } if(m == 2){ cout << "%"; } if(m == 3){ cout << "/"; shu = 0; dfs(); if(!shu) cout << "0"; } return 0; } cpp
by Sparda @ 2019-05-30 17:55:55


@[Sparda](/space/show?uid=48850) 话说你能不能打中文,看不清楚
by gwx123456 @ 2019-05-30 17:56:51


@[gwx123456](/space/show?uid=168385) dabuliao
by Sparda @ 2019-05-30 17:58:43


| 下一页