CF Round #730 (CF1543)

2021/7/8 6:05:47

本文主要是介绍CF Round #730 (CF1543),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

CF Round #730 (Div.2)


A:

给\(a,b\),求\(max\{gcd(a+t, b+t)\}(t \in Z)\)和取得此\(max\)值的\(|t|_{min}\)。当\(max = \infty\)时输出"0 0"。

if (a == b) cout<<"0 0"<<endl;
else
{
	int g = max(a, b)-min(a, b);
	cout<<g<<' ';
	int m = a%g;
	cout<<min(g-m, m)<<endl;
}


B:

数组和不变,求\(min\{\sum\limits_{i=1}^n\sum\limits_{j=i+1}^n|a_i-a_j|\}\)。

int m = sum%n;
cout<<m*(n-m)<<endl;


C:

描述不出来,去看原题吧(

思路:一个裸dfs,注意精度

void dfs(double fac, int e)
{
	double ans = 0, cc = c, mm = m, pp = p;
	if (c > eps)
	{
		if ((c-v) < eps)
		{
			if (m < eps) p += c;
			else m += cc/2.0, p += cc/2.0;
			c = -inf;
			dfs(fac*cc, e+1);
			c = cc; m = mm; p = pp;
		}
		else
		{
			c -= v;
			if (m < eps) p += v;
			else p += v/2.0, m += v/2.0;
			dfs(fac*cc, e+1);
			c = cc; m = mm; p = pp;
		}
	}
	if (m > eps)
	{
		if ((m-v) < eps)
		{
			if (c < eps) p += m;
			else c += mm/2.0, p += mm/2.0;
			m = -inf;
			dfs(fac*mm, e+1);
			c = cc; m = mm; p = pp;
		}
		else
		{
			m -= v;
			if (c < eps) p += v;
			else c += v/2.0, p += v/2.0;
			dfs(fac*mm, e+1);
			c = cc; m = mm; p = pp;
		}
	}
	res += fac*p*e;
}

int T = next();
while(T--)
{
	res = 0;
	cin>>c>>m>>p>>v;
	dfs(1.0, 1);
	printf("%.12llf\n", res);
}


D1:

H2O·Au,看错范围( [0, n) -> [1, n) )了。。。。。。。。。。。。。。。。。

int mask = 0;
rep(i, 0, n)
{
	if (query(i^mask)) break;
	mask ^= (i^mask);
}

\(\color{red}{困了,就先这样吧,没有fst}\)



这篇关于CF Round #730 (CF1543)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程