AtCoder Beginner Contest 174

ABCDEF

（ √：做出； ●：尝试未做出； ○：已补题 ）

A Air Conditioner

#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#include <cstdio>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<LL,LL> P;
{
int x=0,flag=1; char c=getchar();
while((c>'9' || c<'0') && c!='-') c=getchar();
if(c=='-') flag=0,c=getchar();
while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
return flag?x:-x;
}

int main()
{
puts(n>=30?"Yes":"No");

return 0;
}


B Distance

#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#include <cstdio>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<LL,LL> P;
{
int x=0,flag=1; char c=getchar();
while((c>'9' || c<'0') && c!='-') c=getchar();
if(c=='-') flag=0,c=getchar();
while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
return flag?x:-x;
}

int main()
{
while(n--)
{
if(x*x+y*y<=d*d) tot++;
}
cout<<tot;

return 0;
}


C Repsept

#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#include <cstdio>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<LL,LL> P;
{
int x=0,flag=1; char c=getchar();
while((c>'9' || c<'0') && c!='-') c=getchar();
if(c=='-') flag=0,c=getchar();
while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
return flag?x:-x;
}

int main()
{
while(1)
{
if(!x) break;
if(t>1000000) break;
x=x*10+7;
x%=k;
t++;
}
if(!x) cout<<t;
else cout<<"-1";

return 0;
}


D Alter Altar

#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#include <cstdio>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<LL,LL> P;
{
int x=0,flag=1; char c=getchar();
while((c>'9' || c<'0') && c!='-') c=getchar();
if(c=='-') flag=0,c=getchar();
while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
return flag?x:-x;
}

const int maxn=2e5+5;
char s[maxn];
int l,r;

int main()
{
scanf("%s",s+1);
l=1,r=n;
int ans=0;
while(l<=r)
{
while(l<=n && s[l]=='R') l++;
while(r>=1 && s[r]=='W') r--;
if(l<r) swap(s[l],s[r]),ans++;
}
cout<<ans;

return 0;
}


E Logs

#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#include <cstdio>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<LL,LL> P;
{
int x=0,flag=1; char c=getchar();
while((c>'9' || c<'0') && c!='-') c=getchar();
if(c=='-') flag=0,c=getchar();
while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
return flag?x:-x;
}

const int maxn=2e5+5;
LL K,n;
double a[maxn],eps=1e-6;

bool can(double len)
{
LL tot=0;
REP(i,1,n)
{
LL x=a[i]/len;
if(fabs(a[i]-len*x)>eps) x++;
tot+=x-1;
if(tot>K) return 0;
}
return 1;
}

int main()
{
double l=1e-5,r=1e9,mid;
while(l<r-0.000001)
{
mid=(l+r)/2;
if(can(mid)) r=mid;
else l=mid;
}
LL x=r+1-eps;
cout<<x;

return 0;
}


F Range Set Query

#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#include <cstdio>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<LL,LL> P;
{
int x=0,flag=1; char c=getchar();
while((c>'9' || c<'0') && c!='-') c=getchar();
if(c=='-') flag=0,c=getchar();
while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
return flag?x:-x;
}

#define chl k<<1
#define chr k<<1|1

const int maxn=5e5+5;
int a[maxn],book[2*maxn],n,m,tree[maxn*3],t,ans[maxn];
struct node {int l,r,bianhao;};
node h[maxn];

bool cmp(node &a,node &b)
{
return a.r<b.r;
}

void add(int k,int l,int r,int j,int v)
{
if(j<l || j>r) return;
if(l==r && l==j) {tree[k]+=v;return;}
tree[k]+=v;
int mid=(l+r)>>1;
}

int sum(int k,int l,int r,int ll,int rr)
{
if(rr<l || ll>r) return 0;
if(l>=ll && r<=rr) return tree[k];
int mid=(l+r)>>1;
return sum(chl,l,mid,ll,rr)+sum(chr,mid+1,r,ll,rr);
}

int main()
{
sort(h,h+m,cmp);

for(int i=0;i<m;i++)
{
int l=h[i].l,r=h[i].r;
for(int j=t+1;j<=r;j++)
{
else
{
book[a[j]]=j;
}
}
t=r;
ans[h[i].bianhao]=sum(1,1,n,l,r);
}
for(int i=0;i<m;i++)
printf("%d\n",ans[i]);

return 0;
}

03-18 349
04-27 200