牛客周赛 Round 49

嘤嘤不想做计几喵


如果一场比赛的题目总数为 aaa ,计算几何题数量为 bbb 。那么嘤嘤对这场比赛的评价为:(a−b)−b×10(a-b)-b \times 10(a−b)−b×10 。

现在给出一场比赛的题目总数和计算几何题数量,你需要算出嘤嘤对这场比赛的评价喵~。

#include<iostream>

using namespace std;

int main(){
    long long a, b;
    cin >> a >> b;
    cout << (a - b) - b * 10;
    return 0;
}

 嘤嘤不想打怪兽喵


嘤嘤会使用一种魔法:将血量为 xxx 的史莱姆分裂成两只血量为 ⌊x2⌋\lfloor \frac x 2 \rfloor⌊2x​⌋ (即除以 2 向下取整)的史莱姆,当史莱姆血量为 0 时,史莱姆会死亡。

嘤嘤想知道,消灭一只血量为 hhh 的史莱姆最少需要使用几次魔法喵~。

 

 

#include<iostream>

using namespace std;

int main(){
    long long a;
    cin >> a ;
    int k = 0;
    while(a){
        a /= 2;
        k ++;
    }
    long long t = 1;
    long long res = 0;
    for(int i = 0; i < k; i ++){
        res += t;
        t = t * 2;
    }
    cout << res << endl;
    return 0;
}

嘤嘤不想买东西喵



超市正在进行促销活动, nnn 件商品在货架上排成一排,价格都为 xxx ,但是要求每个顾客只能购买一次,且顾客购买的商品必须是货架上连续的一段。

嘤嘤知道每一件商品的原价,现在她想知道购买任意整数件商品最多能省多少钱喵~(省钱的定义为:原价之和减去促销价格之和)。

 

#include<bits/stdc++.h>

using namespace std;

int main(){
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    long long res = 0;
    long long sum = 0;
    for(int i = 0; i < n; i ++){
        cin >> a[i];
        a[i] -= x;
        sum += a[i];
        if(sum < 0)
            sum = 0;
        res = max<long long>(res, sum);
    }  
    cout << res ;
    return 0;
}

嘤嘤不想求异或喵


嘤嘤有两个整数 l,rl,rl,r ,她想知道区间 [l,r][l,r][l,r] 所有整数的异或和是多少喵~。

 

#include<bits/stdc++.h>
using namespace std;
using ll = long long;

const int maxn = 2e5 + 10;
int n, m, k;
ll l, r;

void solve(){
	cin>>l>>r;
	int x = r % 4;
	ll t1 = r - x;
	int y = (l - 1) % 4;
	ll t2 = l - 1 - y;
	ll ans = t1 ^ t2;
	for(ll i = t1 + 1; i <= r; i++){
		ans ^= i;
	}
	for(ll i = t2 + 1; i <= l - 1; i++){
		ans ^= i;
	}
	cout<<ans<<"\n";

}	

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int T = 1;
	cin>>T;
	while(T--){
		solve();
	}
	return 0;
}

嘤嘤不想解方程喵


小红出了一个毒瘤题,但是嘤嘤不会,大家快来帮帮嘤嘤喵~。

求方程 y=a1x2+b1x+c1y=a_1x^2+b_1x+c_1y=a1​x2+b1​x+c1​ 和方程 a2x+b2y+c2=0a_2x+b_2y+c_2=0a2​x+b2​y+c2​=0 联立的解数量。

#include <iostream>
#include <string>
#include <sstream>
#include <algorithm> // Include algorithm for reverse
#include <cassert>

using namespace std;

// Define __int128 for easier use
using int128 = __int128;

// Overload input operator to support int128
istream& operator>>(istream& is, int128& val) {
    string str;
    is >> str;
    val = 0;
    bool neg = false;
    if (str[0] == '-') {
        neg = true;
        str = str.substr(1);
    }
    for (char& c : str) {
        val = val * 10 + (c - '0');
    }
    if (neg) {
        val = -val;
    }
    return is;
}

// Overload output operator to support int128
ostream& operator<<(ostream& os, int128 val) {
    if (val < 0) {
        os << '-';
        val = -val;
    }
    string s;
    do {
        s += char(val % 10 + '0');
        val /= 10;
    } while (val);
    reverse(s.begin(), s.end()); // Use std::reverse to reverse the string
    return os << s;
}

void solve() {
    int128 a1, b1, c1, a2, b2, c2;
    cin >> a1 >> b1 >> c1 >> a2 >> b2 >> c2;

    int128 k = c2 + b2 * c1;
    int128 a = b2 * a1;
    int128 b = a2 + b2 * b1;

    int128 t = b * b - 4 * a * k;

    if(a == 0){
        if(b == 0){
            if(k == 0)
                cout << "INF" << endl;
            else 
                cout << 0 << endl;
        }
        else
            cout << 1 << endl;
    }
    else if (t > 0) {
        cout << 2 << endl;
    } else if (t == 0) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        solve();
    }
    return 0;
}

 

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值