代码:
#include<bits/stdc++.h>
#define ll long long
const int maxn=2e5+10;
struct pt
{
ll l,r;
}a[maxn];
bool cmp1(struct pt x,struct pt y)
{
if(x.l==y.l)return x.r<y.r;
else
return x.l<y.l;
}
using namespace std;
int main()
{
int n;
ll x,d;
ll ans=0;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>x>>d;
a[i].l=x-d;
a[i].r=x+d;
}
sort(a+1,a+1+n,cmp1);
//for(int i=1;i<=n;i++)cout<<a[i].l<<" "<<a[i].r<<endl;
ll p=a[1].l,q=a[1].r;
for(int i=2;i<=n;i++)
{
if(a[i].l<=q)q=max(a[i].r,q);
if(a[i].l>q)
{
ans+=a[i].l-q;
q=a[i].r;
}
}
cout<<ans<<endl;
return 0;
}
代码:
#include<bits/stdc++.h>
using namespace std;
void solve()
{
double r,x,y,d;
double dd,a1,a2,ans;//圆心和Q的距离
cin>>r;
cin>>x>>y>>d;
dd=sqrt(x*x+y*y);
a1=acos((dd-d)/r);
a2=acos((dd+d)/r);
//cout<<a1<<" "<<a2<<endl;
ans=r*(a1-a2);
printf("%.12lf\n",ans);
}
int main()
{
int t;
cin>>t;
while(t--)
{
solve();
}
return 0;
}
代码:
#include<bits/stdc++.h>
using namespace std;
void solve()
{
string s;
cin>>s;
int temp=0;
if(s.size()>1)
{
for(int i=0;i<s.size()-1;i++)
{
if(s[i]!='9')
{
temp=1;
break;
}
}
if(temp)
{
for(int i=1;i<s.size();i++)cout<<"9";cout<<endl;
}
else cout<<s<<endl;
}
else cout<<s<<endl;
}
int main()
{
solve();
return 0;
}