恶意评分?

P1106 删数问题

@[璀璨星空1](/space/show?uid=130897) orz这不是个贪心的例题吗
by disangan233 @ 2019-01-25 18:15:31


是不是我算法的问题? ~~我用的递归~~
by 璀璨星空1 @ 2019-01-25 18:19:14


# 请勿抄 ```cpp #include<bits/stdc++.h> const int X=250; const char ERR=' '; char a[X+5]; int n,del,h; void cross(int sta,int end,int num) { int l=0,mnw=127,mnp; for(int i=sta;i<=end;i++) if(a[i]!=ERR) l++; if(num==0) return; else if(num==l) { for(int i=sta;i<=end;i++) a[i]=ERR; return; } else { for(int i=sta;i<=sta+num;i++) { if(a[i]==ERR) continue; if(a[i]<mnw) mnw=a[i],mnp=i; } if(mnp==1) cross(sta+1,end,num); else { int t=0; for(int i=sta;i<mnp;i++) a[i]=ERR,t++; cross(mnp+1,end,num-t); } } return; } void SOLVE() { scanf("%s%d",(a+1),&del); n=strlen(a+1); cross(1,n,del); for(int i=1;i<=n;i++) { if(a[i]!='0'&&a[i]!=ERR) h=1; if((h||i==n)&&(a[i]!=ERR)) printf("%c",a[i]); } printf("\n"); system("pause"); return; } int main() { SOLVE(); return 0; } ```
by 璀璨星空1 @ 2019-01-25 18:19:45


@[璀璨星空1](/space/show?uid=130897) 递归也是普及-啊。
by disangan233 @ 2019-01-25 18:20:11


``` #include<bits/stdc++.h> using namespace std; int s; string n; #define re register int int main() { string n; cin>>n>>s; int len=n.length(); for(re i=1;i<=s;i++,len--) for(re j=0;j<=len-1;j++) if(n[j]>n[j+1]) { for(re k=j;k<len-1;k++) n[k]=n[k+1]; break; } re p=0; while(n[p]=='0') p++; for(re j=p;j<len;j++) cout<<n[j]; if(p>len) puts("0"); return 0; } ```
by disangan233 @ 2019-01-25 18:21:32


emmm ~~咋这么长~~ ``` #include<stdio.h> char s[10000002]; int k; int main(){ scanf("%s%d",s,&k); int i=0,j=1; while(s[j-1]!=0){ if(k<=0||s[i]<=s[j])s[++i]=s[j++]; else{ i--;k--; } } for(i=0;s[i]=='0';i++); printf("%s\n",s+i); } ```
by jerry3128 @ 2019-01-25 18:21:40


泥萌怎么定义的普及+啊 普及+应该和今年普及T4差不多吧
by Nova_守门员 @ 2019-01-25 18:21:40


额 额额 额额额 额额额额 额额额额额
by 璀璨星空1 @ 2019-01-25 18:22:06


``` for(;;printf("额");) ```
by 璀璨星空1 @ 2019-01-25 18:22:36


尴尬。。
by 行者_Walker @ 2019-01-25 18:22:44


| 下一页