zoukankan      html  css  js  c++  java
  • 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{sumlimits_{i=1}^nsumlimits_{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
    ", 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})

  • 相关阅读:
    linux自动清理30天之前的文件
    Oracle树查询及相关函数
    jackson循环引用导致序列化stackOverFlow的解决
    java核心技术36讲笔记
    Quartz学习
    Quartz学习
    java核心技术36讲
    git常用命令
    CTCall简介(后续会继续补充)
    自定义导航栏,隐藏导航栏底部的灰色线条
  • 原文地址:https://www.cnblogs.com/Loxilante/p/CF1543.html
Copyright © 2011-2022 走看看