contest 1.13
Posted lllxq
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了contest 1.13相关的知识,希望对你有一定的参考价值。
A.发财兔1A
O(nlogn)
#include <iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<map> typedef long long ll; using namespace std; ll n,num; ll a[1000005]; ll b[1000005]; ll cnt[1000005]; ll getid(ll x){ return lower_bound(b+1,b+1+num,x)-b; } int main() { scanf("%lld",&n); for(ll i=1;i<=n;i++){ scanf("%lld",&a[i]); b[i]=a[i]; } sort(a+1,a+1+n); sort(b+1,b+1+n); num=unique(b+1,b+1+n)-(b+1); for(ll i=1;i<=n;i++){ ll id=getid(a[i]); cnt[id]++; } ll ans=0; for(ll i=1;i<=n;i++){ ll now=1; while(now<=2*a[n]){ if(now<a[i]||now-a[i]<a[i]) {now*=2;continue;} ll id=getid(now-a[i]); if(b[id]==now-a[i]){ ans+=cnt[id]; if(now-a[i]==a[i]) {ans--;cnt[getid(a[i])]--;} } now*=2; } } printf("%lld ",ans); return 0; }
C.发财兔1C
E.bomb
#include <iostream> #include<cstdio> #include<cmath> #include<cstring> #include<algorithm> #include<map> #define inf 0x3f3f3f3f using namespace std; map<double,int> mp; struct Node{ int x,y; }node[1205]; double getk(Node a,Node b){ double x=a.x-b.x; double y=a.y-b.y; if(y==0) return 0; else if(x==0) return inf; else return y*1.0/(x*1.0); } int main() { int n;scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d%d",&node[i].x,&node[i].y); } int ans=1; for(int i=1;i<=n;i++){ int cnt=1; mp.clear(); for(int j=1;j<=n;j++){ if(j==i) continue; double k=getk(node[i],node[j]); mp[k]++; cnt=max(cnt,mp[k]+1); } ans=max(ans,cnt); } printf("%d ",ans); return 0; }
F.matrix
以上是关于contest 1.13的主要内容,如果未能解决你的问题,请参考以下文章
[Codeforces Round #522 (Div. 2, based on Technocup 2019 Elimination Round 3)][C. Playing Piano](代码片段
FlinkFlink 1.13 版本 SavePoint 源码分析