Codeforces Round #262 (Div. 2) Conclusion: binary,
B. Little Dima and Equation
Idea: the first two questions were quickly developed, and ranting should be able to increase. Then I thought the code was okay. I thought of a group of cha data, and then I locked it, then, just after the lock, someone else cha saw the code and found that Nima forgot to judge whether it was less than 10 ^ 9. Then C would not be in the mood after thinking about many methods, in this way, rating is downgraded again.
#pragma comment(linker, "/STACK:1024000000,1024000000")#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<map>#include<queue>#include<set>#include<cmath>#include<bitset>#define mem(a,b) memset(a,b,sizeof(a))#define lson i<<1,l,mid#define rson i<<1|1,mid+1,r#define llson j<<1,l,mid#define rrson j<<1|1,mid+1,r#define INF 6#define maxn 10005typedef long long ll;typedef unsigned long long ull;using namespace std;int i,j;ll k,a,b,c,sum,n,m;double aa,bb,cc,sum1;string s,ss,str;ll abc(ll x){ ll sum=0; while(x) { sum+=x%10; x/=10; } return sum;}ll go(ll f){ ll sum=1; for(int i=0;i<a;i++) sum*=f; return sum;}ll nn[100010],mm=1000000000;int main(){ cin>>a>>b>>c; for(i=1;i<82;i++) { sum=go(i)*b+c; n=sum; if(abc(sum)==(ll)i) nn[j++]=sum; } printf("%d\n",j); for(i=0;i<j;i++) { if(i!=j-1) cout<<nn[i]<<' '; else cout<<nn[i]<<endl; } return 0;}
C. Present
Idea: I can't think of this question all the time. I just understood it at a glance.
As mentioned in the question solution, the minimum and maximum values for such requests are generally two points ...... I didn't even think about it because I was too weak.
From scratch, the first less than x must add x-a [I], so it must be the leftmost of a continuous segment, add x-a [I] to the [I] section of this section, and continue to scan for the first one that is less than x. This is so simple...
But it took only one night to get there, Nima. It turned out to be r = INF in binary mode. Then, it would be because a [I] might be added, and then it would be more than int, but it turns out wrong when I replace all of them with long. There are always 15th examples of WA. I don't know what's going on, but I have handed in a lot of posts and I still don't know what's going on, you can change it to r = 1100000000 later. The addition of a [I] is exactly at the int boundary, so it is only. Dizzy ......
#pragma comment(linker, "/STACK:1024000000,1024000000")#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<map>#include<queue>#include<set>#include<cmath>#include<bitset>#define mem(a,b) memset(a,b,sizeof(a))#define lson i<<1,l,mid#define rson i<<1|1,mid+1,r#define llson j<<1,l,mid#define rrson j<<1|1,mid+1,r#define INF 0x7fffffff#define maxn 200005typedef long long ll;typedef unsigned long long ull;using namespace std;int n,m,w,a[maxn],b[maxn];bool check(ll mid){ int sum=0,cnt=0; mem(b,0); for(int i=0;i<n;i++) { sum+=b[i]; if(sum+a[i]<mid) { cnt+=mid-(sum+a[i]); if(cnt>m) return false; b[i+w]-=mid-(sum+a[i]); sum+=mid-(sum+a[i]); } } return true;}int binary(){ int l=1,r=1100000000,mid; while(l<=r) { mid=(l+r)>>1; if(check(mid)) l=mid+1; else r=mid-1; } return r;}int main(){ cin>>n>>m>>w; for(int i=0;i<n;i++) cin>>a[i]; cout<<binary()<<endl; return 0;}