Codeforces Round #635 (Div. 2)---题解(AB)

A. Ichihime and Triangle

题目
传送门

题意
从区间[a,b][b,c][c,d]中选取三个数,以此为三边构成三角形,输出这三个数

毕竟是A题,思路肯定比较简单,就找特殊的三角形嘛,等边肯定不行,然后发现等腰可以,即a,c,c

代码

#include<iostream>
using namespace std;
typedef long long ll;
int main()
{
	ll a, b, c, d;
	int t;
	cin >> t;
	while (t--)
	{
		cin >> a >> b >> c >> d;
		cout << a << ' ' <<c<< ' ' << c << endl;
	}
	return 0;
}

B. Kana and Dragon Quest game

题目:
传送门

题意:
给定h,操作1、2上限n、m。
操作1:h⇒⌊h/2⌋+10
操作2:h⇒h−10

思路:
操作2能够减去的数字是固定的。对于操作1,当h⩾20时h始终下降,并且h越大减的越多。
先进行操作1,再操作2,判断最后是不是小于等于0。

代码:

#include<iostream>
using namespace std;
int main() 
{
    int t;
    cin >> t;
    while (t--) 
    {
        int x, n, m;
        cin >> x >> n >> m;
        while ((x / 2 + 10) < x && n) 
        {
            x = x / 2 + 10;
            n--;
        }
        x -= m * 10;
        while ((x / 2 + 10) < x && n) 
        {
            x = x / 2 + 10;
            n--;
        }
        if (x > 0)
            cout << "NO\n";
        else
            cout << "YES\n";
    }
    return 0;
}

码字不易,留个赞吧~

发布了50 篇原创文章 · 获赞 63 · 访问量 6212

猜你喜欢

转载自blog.csdn.net/SDAU_LGX/article/details/105582952