您的位置:首页 > 汽车 > 时评 > Recording题集

Recording题集

2024/10/5 11:49:58 来源:https://blog.csdn.net/weixin_73164943/article/details/141968974  浏览:    关键词:Recording题集

阶段1000-1300

Problem - 2002C - Codeforces

//如果圆比点先到,则不可能进入
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define pii pair<int,int>
signed main() {const int N = 1e5 + 7;//最多一个循环pii arr[N], from, to;int a, b, n;int nn; cin >> nn; while (nn--) {cin >> n;int i = -1; while (++i < n) {cin >> a >> b;arr[i] = { a,b };}cin >> a >> b; from = { a,b };cin >> a >> b; to = { a,b };auto dic = [&](pii t) {//点t到终点to的距离的平方return (to.first-t.first)*(to.first - t.first)\+ (to.second-t.second)*(to.second - t.second);};int limit = dic(from);// printf("limit的值%lld\n", limit);i = -1; while (++i < n) {int th = dic(arr[i]);//当数据很大且二者相近时,分不出区别// cout<<th<<endl;if (th<=limit) {i = -1;// printf("这里(%d,%d)超了,为%lld\n", arr[i].first, arr[i].second, th);break;}}if (i == -1)cout << "NO" << endl;else cout << "YES" << endl;}
}

Problem - 1999E - Codeforces

这里Find难判断,容易错,实际上是向下取整而不是四舍五入,剩下的就是对暴力的优化了

可以用前缀和,然后还可以建立一个f组来存边界提前打表,用二分来优化那个递归,虽然没什么必要

auto Find=[&](int x){//查看x到0需要几步

return lower_bound(f,f+tt,x)-f;

};

#include<bits/stdc++.h>
using namespace std;
int main(){const int N=2*1e5+7;int nn;cin>>nn;//填充fint s[N];s[0]=0;auto Find=[&](int x){int cnt=0;while(x){x/=3;cnt++;}return cnt;};for(int i=1;i<N;i++){s[i]=s[i-1]+Find(i);}while(nn--){int l,r;cin>>l>>r;int ans=s[l]-s[l-1];cout<<ans*2+s[r]-s[l]<<endl;}
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com