ABC234 总结

成绩:image
(惨败)

A题,写成一个函数,题目怎么说就怎么做。

B题,直接 \(O(n^2)\) 枚举,调了好久,最后发现是欧式距离写错了。于是我得到了经验,欧式距离不能再记错了(\(dis=\sqrt{(x_i-x_j)^2+(y_i-y_j)^2}\))。

C题一看,拿出计算器算了一下前几个样例,发现就是输出一个数的二进制,只是把二进制里的1改成2。遇到这种题可以往二进制的方向去想。

D题还是想了一会儿才想出了。一开始以为要套个数据结构维护,后来凭借经验认为应该要倒着来,不过没深究。后来再想一想倒着来,然后考虑每个删去的贡献,就打出来了。这种题要可以尝试考虑倒着来。

E题,开这题时发现翻译坏了,这能凭我的垃圾英语来理解。在纸上推了推,发现一个数大于9876543210只能是每位相同,一个数大于86420相邻最多相差1,于是86420一下暴力枚举,9876543210以上直接构造。就是中间那个区域调了一个小时,又有上升又有下降,最后没调出来。60个点WA了三个点。

题解的思路好像很巧妙的,不过没看。(坑 \(\times 1\)

后面的题没看。

A题Code
// Problem: A - Weird Function
// Contest: AtCoder - AtCoder Beginner Contest 234
// URL: https://atcoder.jp/contests/abc234/tasks/abc234_a
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;
ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+
(x<<3)+(ch^48);ch=getchar();}return x*f;}
//#define M
//#define mo
//#define N
int n, m, i, j, k, t; 

int f(int x)
{
	return x*x+2*x+3; 
}

signed main()
{
//	freopen("tiaoshi.in", "r", stdin); 
//	freopen("tiaoshi.out", "w", stdout); 
	t=read();  
	printf("%lld",  f(f(f(t)+t)+f(f(t)))); 
	return 0; 
}

B题Code
// Problem: B - Longest Segment
// Contest: AtCoder - AtCoder Beginner Contest 234
// URL: https://atcoder.jp/contests/abc234/tasks/abc234_b
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;
//#define int long long
inline int read(){int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;
ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+
(x<<3)+(ch^48);ch=getchar();}return x*f;}
//#define M
//#define mo
#define N 1010
int n, i, j, k; 
double m, x[N], y[N]; 

double pf(double x)
{
	return x*x; 	
} 

double dis(int i, int j)
{	
	// printf("dis(%d, %d)=%lf\n", i, j, sqrt(pf(x[i]-x[j])+pf(y[i]-y[j]))); 
	return sqrt(pf(x[i]-x[j])+pf(y[i]-y[j]));  
}

signed main()
{
//	freopen("tiaoshi.in", "r", stdin); 
//	freopen("tiaoshi.out", "w", stdout); 
	n=read(); 
	for(i=1; i<=n; ++i) scanf("%lf%lf", &x[i], &y[i]); 
	for(i=1; i<=n; ++i)
		for(j=1; j<=n; ++j)
			m=max(m, dis(i, j)); 
	printf("%.10f", m); 
	return 0; 
}

C题Code
// Problem: C - Happy New Year!
// Contest: AtCoder - AtCoder Beginner Contest 234
// URL: https://atcoder.jp/contests/abc234/tasks/abc234_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;
ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+
(x<<3)+(ch^48);ch=getchar();}return x*f;}
//#define M
//#define mo
//#define N
int n, m, i, j, k; 

signed main()
{
//	freopen("tiaoshi.in", "r", stdin); 
//	freopen("tiaoshi.out", "w", stdout); 
	n=read(); 
	for(k=62; k>=0; --k)
		if((n>>k)&1) break; 
	for(i=k; i>=0; --i)
		printf("%d", ((n>>i)&1) ? 2 : 0); 
	return 0; 
}

D题Code
// Problem: D - Prefix K-th Max
// Contest: AtCoder - AtCoder Beginner Contest 234
// URL: https://atcoder.jp/contests/abc234/tasks/abc234_d
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;
#define int long long 
inline int read(){int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;
ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+
(x<<3)+(ch^48);ch=getchar();}return x*f;}
//#define M
//#define mo
#define N 500010
struct node
{
	int x, id; 
}a[N]; 
int n, m, i, j, k; 
int ans[N], p[N], b[N]; 

bool cmp(node x, node y)
{
	return x.x>y.x; 
}

signed main()
{
//	freopen("tiaoshi.in", "r", stdin); 
//	freopen("tiaoshi.out", "w", stdout); 
	n=read(); m=k=read(); 
	for(i=1; i<=n; ++i) a[i].x=read(), a[i].id=i; 
	sort(a+1, a+n+1, cmp); 
	for(i=1; i<=n; ++i) p[a[i].id]=i; 
	for(i=n; i>=m; --i)
	{
		// printf("%lld\n", k); 
		ans[i]=a[k].x; 
		b[p[i]]=1; 
		if(p[i]<=k) while(b[++k]); 
	}
	for(i=m; i<=n; ++i) printf("%lld\n", ans[i]); 
	return 0; 
}

E题调不出Code
// Problem: E - Arithmetic Number
// Contest: AtCoder - AtCoder Beginner Contest 234
// URL: https://atcoder.jp/contests/abc234/tasks/abc234_e
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;
ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+
(x<<3)+(ch^48);ch=getchar();}return x*f;}
//#define M
//#define mo
//#define N
int n, m, i, j, k, a[10]; 

int digit(int x)
{
	int ans=0; 
	while(x) x/=10, ++ans; 
	return ans; 
}

int mx(int x)
{
	int ans=0; 
	while(x)
	{
		if(x%10>j) ans=1; 
		if(x%10<j) ans=0; 
		x/=10; 
	}
	return ans; 
}

int firstx(int x)
{
	while(x>=10) x/=10; 
	return x; 
}

int pan(int n)
{
	int i=n%10, j, k=n%10-n/10%10; 
	n/=10; 
	while(n)
	{
		j=n%10; 
		if(i-j!=k) return 0; 
		i=j; 
		n/=10; 
	}
	return 1; 
}

int panx(int n)
{
	int k=firstx(n), i; 
	for(i=0; n; ++i)
		if(n%10>k-(m-i)+1) return 0; 
		else n/=10; 
	return 1; 
}

int pany(int n)
{
	int ans=1; 
	if(i+m-1>9) return 0; 
	int j=1; 
	while(n)
	{
		if(n%10>i+m-j) ans=0; 
		if(n%10<i+m-j) ans=1; 
		n/=10; ++j; 
	}
	return ans; 
}

int tong(int n)
{
	int i=firstx(n), j, k=0; 
	for(j=1; j<=m; ++j) k=k*10+i; 
	return k; 
}

int shangsheng(int n)
{
	int i=firstx(n), j, k=0; 
	if(9-i+1<m) return 0x7fffffffffffffff; 
	for(j=1; j<=m; ++j, ++i) k=k*10+i; 
	return k; 
}

int xiajiang(int n)
{
	int i=firstx(n), j, k=0; 
	if(i+1<m) return 0x7fffffffffffffff; 
	for(j=1; j<=m; ++j, --i) k=k*10+i; 
	return k; 
}

int jyxj(int x)
{
	int i=firstx(n)+1, j, k=0; 
	if(i==10) return 0x7fffffffffffffff; 
	if(i+1<m) return 0x7fffffffffffffff; 
	for(j=1; j<=m; ++j, --i) k=k*10+i; 
	return k; 
}

int jyss(int x)
{
	int i=firstx(n)+1, j, k=0; 
	if(i==10) return 0x7fffffffffffffff; 
	if(9-i+1<m) return 0x7fffffffffffffff; 
	for(j=1; j<=m; ++j, ++i) k=k*10+i; 
	return k; 
}

int jy(int x)
{
	int k=0, i; 
	for(i=0; i<=m; ++i) k=k*10+1;  
	return k; 
}

signed main()
{
//	freopen("tiaoshi.in", "r", stdin); 
//	freopen("tiaoshi.out", "w", stdout); 
	n=read(); m=digit(n); 
	if(m==1) return printf("%lld", n), 0; 
	if(n>86420)
	{
		if(n>9876543210) 
		{
			j=firstx(n); 
			if(mx(n)) ++j; 
			for(i=1; i<=m; ++i) printf("%lld", j);
			return 0; 
		} 
		else
		{
			a[1]=tong(n); a[2]=shangsheng(n); a[3]=xiajiang(n); 
			a[4]=jyxj(n); a[5]=jyss(n); a[6]=jy(n);
			sort(a+1, a+7); 
			for(i=1; i<=6; ++i)
				if(a[i]>=n) return printf("%lld", a[i]), 0; 
			return 0; 	
		}
	}
	for(; ; ++n) if(pan(n)) return printf("%lld", n), 0; 
	return 0; 
}

posted @ 2022-01-09 10:35  zhangtingxi  阅读(540)  评论(0编辑  收藏  举报