为什么全是RE,手测无误。。

P1106 删数问题

大佬,你输入的K可是一个**高精度的正整数**
by Chen·Jh @ 2019-06-02 15:02:44


@[cqsbz_cxy](/space/show?uid=185515) 试试`__int128`? 记得写一个快读,这个没有定义标准输入输出
by Jelly_Goat @ 2019-06-02 15:53:26


@[Chen·Jh](/space/show?uid=90534) 有啥区别。、。字节长度么
by cqsbz_cxy @ 2019-06-02 16:30:44


@[Jelly_Goat](/space/show?uid=122927) ```c #include<bits/stdc++.h> #include<cstring> #include<string> #include<iostream> using namespace std; long long ans[300002]; long long que1[300002]; long long que2[300002]; char num[1000],y[10000]; int K,M,x[300005],lon=1,len; unsigned long long a; string n; char ans2[300005]; int main() { cin>>K>>M; ans[1]=1; sprintf(ans2,"%d",ans[1]); n+=ans2; int head1=1,head2=1; for(int i=1;i<K;i++){ que1[i]=2*ans[i]+1; que2[i]=4*ans[i]+5; if(que1[head1]<que2[head2]) ans[i+1]=que1[head1++]; else ans[i+1]=que2[head2++]; sprintf(ans2,"%d",ans[i+1]); n+=ans2; } cout<<n<<endl; len=n.length(); while(M>0) { for(int i=0;i<len;i++) if(n[i]<n[i+1]) { n.erase(i,1); break; } else if(n[i]<n[i-1]&&n[i]<n[i+1]) n.erase(i,1); M--; } if(n.size()==0) cout<<"0"<<endl; else { int m=0; for(int i=0;i<n.length();i++) { if(n[i]-'0'!=0) m=1; if(m==1) cout<<n[i]-'0'; } if(m==0) cout<<"0"; cout<<endl; } } ///这是改了之后的,应该能过了
by cqsbz_cxy @ 2019-06-02 16:32:23


```c #include<bits/stdc++.h> #include<cstring> #include<string> #include<iostream> using namespace std; long long ans[300002]; long long que1[300002]; long long que2[300002]; char num[1000],y[10000]; int K,M,x[300005],lon=1,len; unsigned long long a; string n; char ans2[300005]; int main() { cin>>K>>M; ans[1]=1; sprintf(ans2,"%d",ans[1]); n+=ans2; int head1=1,head2=1; for(int i=1;i<K;i++){ que1[i]=2*ans[i]+1; que2[i]=4*ans[i]+5; if(que1[head1]<que2[head2]) ans[i+1]=que1[head1++]; else ans[i+1]=que2[head2++]; sprintf(ans2,"%d",ans[i+1]); n+=ans2; } cout<<n<<endl; len=n.length(); while(M>0) { for(int i=0;i<len;i++) if(n[i]<n[i+1]) { n.erase(i,1); break; } else if(n[i]<n[i-1]&&n[i]<n[i+1]) n.erase(i,1); M--; } if(n.size()==0) cout<<"0"<<endl; else { int m=0; for(int i=0;i<n.length();i++) { if(n[i]-'0'!=0) m=1; if(m==1) cout<<n[i]-'0'; } if(m==0) cout<<"0"; cout<<endl; } } ```
by cqsbz_cxy @ 2019-06-02 16:32:38


大佬,你能用字符串输入吗? ```cpp #include <bits/stdc++.h> using namespace std; int main(){ string st; cin>>st; int k; cin>>k; while(k--){ for(int i=0;i<(int)st.size();i++){ if(st[i]>st[i+1]){ st.erase(i,1); break; } } while(st[0]=='0'&&st.size()!=1) st.erase(0,1); } cout<<st<<"\n"; return 0; } ```
by LYR_ @ 2019-06-09 18:38:53


|