牛客高校校赛-香港城市大学(东莞)2024新生排位赛(A,C,E,G,H)

传送门

A - Automation Machine

分析

  • 这题是个纸老虎,只需要对两个操作进行模拟即可,需要注意开 l o n g   l o n g long \space long long long
#include<bits/stdc++.h>
using std::cin;
using std::cout;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using pii = std::pair<int, int>;
#define TESTS int _; std::cin >> _; while(_--)
#define all(a) a.begin(), a.end()
#define all1(a) a.begin() + 1, a.end()
#define pb push_back
#define fi first
#define se second
#define SUM(v) std::accumulate(all(v), 0LL)
#define SUM1(v) std::accumulate(all1(v), 0LL)
#define MIN(v) *std::min_element(all(v))
#define MIN1(v) *std::min_element(all1(v))
#define MAX(v) *std::max_element(all(v))
#define MAX1(v) *std::max_element(all1(v))

constexpr i64 inf = 1E18, Md3 = 998244353, Md7 = 1e9 + 7;
constexpr double eps = 1E-9;

int main() {
	
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
		
	i64 n, t;
	cin >> n >> t;
	i64 sum = 0;
	i64 ans = 0;
	while(t--) {
		int op;
		cin >> op;
		if(op == 1) {
			i64 k;
			cin >> k;
			sum += k;
			if(sum >= n) {
				ans++;
				sum = 0;
			}
		} else {
			cout << ans << "\n";
		}
	}

	return 0;
}

C - Love Game

分析

  • 这题是个博弈题,首先考虑最简单的情况
  • n = 1 n = 1 n=1 A l i c e Alice Alice 可以一次取完
  • n = 2 n = 2 n=2 A l i c e Alice Alice 可以一次取完
  • n = 3 n = 3 n=3 A l i c e Alice Alice 只能取一个,剩下的两个 B o b Bob Bob 会取完
  • n = x n = x n=x, 如果 x x x t t t 的倍数,那么 A l i c e Alice Alice 可以让 x x x 变成 n = x − t n = x - t n=xt n = x − 1 n = x - 1 n=x1 的状态,如果这两种状态都是先手赢,那么 A l i c e Alice Alice 必输,反之可以保证 A l i c e Alice Alice
  • 最终会发现一个规律,当 n ∈ [ 1 , 9 ] n \in \lbrack1, 9 \rbrack n[1,9] 时,胜利的结果是 A , A , B , A , A , B , A , A , B A,A,B,A,A,B,A,A,B A,A,B,A,A,B,A,A,B,当 n ≥ 10 n \ge 10 n10 时,呈现奇偶性
#include<bits/stdc++.h>
using std::cin;
using std::cout;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using pii = std::pair<int, int>;
#define TESTS int _; std::cin >> _; while(_--)
#define all(a) a.begin(), a.end()
#define all1(a) a.begin() + 1, a.end()
#define pb push_back
#define fi first
#define se second
#define SUM(v) std::accumulate(all(v), 0LL)
#define SUM1(v) std::accumulate(all1(v), 0LL)
#define MIN(v) *std::min_element(all(v))
#define MIN1(v) *std::min_element(all1(v))
#define MAX(v) *std::max_element(all(v))
#define MAX1(v) *std::max_element(all1(v))


constexpr i64 inf = 1E18, Md3 = 998244353, Md7 = 1e9 + 7;
constexpr double eps = 1E-9;


int main() {
	
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
		
	TESTS {
		int n;
		cin >> n;
		if(n == 1 || n == 2 || n == 4 || n == 5 || n == 7 || n == 8 || n == 10) {
			cout << "Alice\n";
		} else if(n == 3 || n == 6 || n == 9) {
			cout << "Bob\n";
		} else {
			if(n & 1) {
				cout << "Bob\n";
			} else {
				cout << "Alice\n";
			}
		}
	}

	return 0;
}

E - Selecting Majors

分析

  • 这题同样是个纸老虎,只需要对 a , b , c , d a, b, c, d a,b,c,d 除 30 向上取整即可
#include<bits/stdc++.h>
using std::cin;
using std::cout;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using pii = std::pair<int, int>;
#define TESTS int _; std::cin >> _; while(_--)
#define all(a) a.begin(), a.end()
#define all1(a) a.begin() + 1, a.end()
#define pb push_back
#define fi first
#define se second
#define SUM(v) std::accumulate(all(v), 0LL)
#define SUM1(v) std::accumulate(all1(v), 0LL)
#define MIN(v) *std::min_element(all(v))
#define MIN1(v) *std::min_element(all1(v))
#define MAX(v) *std::max_element(all(v))
#define MAX1(v) *std::max_element(all1(v))

constexpr i64 inf = 1E18, Md3 = 998244353, Md7 = 1e9 + 7;
constexpr double eps = 1E-9;


int main() {
	
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	
	TESTS {
		i64 a, b, c, d;
		cin >> a >> b >> c >> d;
		cout << (a + 29) / 30 + (b + 29) / 30 + (c + 29) / 30 + (d + 29) / 30 << "\n";
	}


	return 0;
}

G - Waylon Tritangle

分析

  • 这题明显是一个排列组合的变种,要解决的其实就是对每一行涂色有多少种情况
  • 当我把前六行算出来时,发现这六个数分别是 1   2   3   5   8   13 1\space2\space 3\space 5\space 8\space 13 1 2 3 5 8 13,这不就是斐波那契吗?于是直接写
#include<bits/stdc++.h>
using std::cin;
using std::cout;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using pii = std::pair<int, int>;
#define TESTS int _; std::cin >> _; while(_--)
#define all(a) a.begin(), a.end()
#define all1(a) a.begin() + 1, a.end()
#define pb push_back
#define fi first
#define se second
#define SUM(v) std::accumulate(all(v), 0LL)
#define SUM1(v) std::accumulate(all1(v), 0LL)
#define MIN(v) *std::min_element(all(v))
#define MIN1(v) *std::min_element(all1(v))
#define MAX(v) *std::max_element(all(v))
#define MAX1(v) *std::max_element(all1(v))

constexpr i64 inf = 1E18, Md3 = 998244353, Md7 = 1e9 + 7;
constexpr double eps = 1E-9;


// TODO: Dynamic ModInt
 
template<typename T>
constexpr T power(T a, u64 b) {
    T res {1};
    for (; b != 0; b /= 2, a *= a) {
        if (b % 2 == 1) {
            res *= a;
        }
    }
    return res;
}
 
template<u32 P>
constexpr u32 mulMod(u32 a, u32 b) {
    return 1ULL * a * b % P;
}
 
template<u64 P>
constexpr u64 mulMod(u64 a, u64 b) {
    u64 res = a * b - u64(1.L * a * b / P - 0.5L) * P;
    res %= P;
    return res;
}
 
template<typename U, U P>
requires std::unsigned_integral<U>
struct ModIntBase {
public:
    constexpr ModIntBase() : x {0} {}
    
    template<typename T>
    requires std::integral<T>
    constexpr ModIntBase(T x_) : x {norm(x_ % T {P})} {}
    
    constexpr static U norm(U x) {
        if ((x >> (8 * sizeof(U) - 1) & 1) == 1) {
            x += P;
        }
        if (x >= P) {
            x -= P;
        }
        return x;
    }
    
    constexpr U val() const {
        return x;
    }
    
    constexpr ModIntBase operator-() const {
        ModIntBase res;
        res.x = norm(P - x);
        return res;
    }
    
    constexpr ModIntBase inv() const {
        return power(*this, P - 2);
    }
    
    constexpr ModIntBase &operator*=(const ModIntBase &rhs) & {
        x = mulMod<P>(x, rhs.val());
        return *this;
    }
    
    constexpr ModIntBase &operator+=(const ModIntBase &rhs) & {
        x = norm(x + rhs.x);
        return *this;
    }
    
    constexpr ModIntBase &operator-=(const ModIntBase &rhs) & {
        x = norm(x - rhs.x);
        return *this;
    }
    
    constexpr ModIntBase &operator/=(const ModIntBase &rhs) & {
        return *this *= rhs.inv();
    }
    
    friend constexpr ModIntBase operator*(ModIntBase lhs, const ModIntBase &rhs) {
        lhs *= rhs;
        return lhs;
    }
    
    friend constexpr ModIntBase operator+(ModIntBase lhs, const ModIntBase &rhs) {
        lhs += rhs;
        return lhs;
    }
    
    friend constexpr ModIntBase operator-(ModIntBase lhs, const ModIntBase &rhs) {
        lhs -= rhs;
        return lhs;
    }
    
    friend constexpr ModIntBase operator/(ModIntBase lhs, const ModIntBase &rhs) {
        lhs /= rhs;
        return lhs;
    }
    
    friend constexpr std::ostream &operator<<(std::ostream &os, const ModIntBase &a) {
        return os << a.val();
    }
    
    friend constexpr bool operator==(ModIntBase lhs, ModIntBase rhs) {
        return lhs.val() == rhs.val();
    }
    
    friend constexpr bool operator!=(ModIntBase lhs, ModIntBase rhs) {
        return lhs.val() != rhs.val();
    }
    
    friend constexpr bool operator<(ModIntBase lhs, ModIntBase rhs) {
        return lhs.val() < rhs.val();
    }
    
private:
    U x;
};
 
template<u32 P>
using ModInt = ModIntBase<u32, P>;
 
template<u64 P>
using ModInt64 = ModIntBase<u64, P>;
 
constexpr u32 P = 998244353;
using Z = ModInt<P>;


Z presum[100005], preans[100005];
void init() {
	presum[1] = 1;
	presum[2] = 2;
	for(int i = 3; i <= 100000; i++) {
		presum[i] = presum[i - 1] + presum[i - 2];
	}
	preans[1] = 1;
	for(int i = 2; i <= 100000; i++) {
		preans[i] = preans[i - 1] * presum[i];
	}
}
int main() {
	
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
		
	init();
	TESTS {
		int n;
		cin >> n;
		cout << preans[n] << "\n";
	}

	return 0;
}

H - Xor Perfect

分析

  • 要使这 n n n 个数的异或和是 n n n 的因子,由于相同的两个值异或的值为 0 0 0 所以当 n n n为奇数时,我们可以让前 n − 1 n - 1 n1 个数相等,让最后一个数等于 n n n 即可,当 n n n 为偶数时,样例已经给了一个提示,那就是前 n − 1 n - 1 n1 个数都为 1 1 1 那么最后会剩下一个 1 1 1 我们再让其与 3 3 3 异或就可以得到 2 2 2
#include<bits/stdc++.h>
using std::cin;
using std::cout;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using pii = std::pair<int, int>;
#define TESTS int _; std::cin >> _; while(_--)
#define all(a) a.begin(), a.end()
#define all1(a) a.begin() + 1, a.end()
#define pb push_back
#define fi first
#define se second
#define SUM(v) std::accumulate(all(v), 0LL)
#define SUM1(v) std::accumulate(all1(v), 0LL)
#define MIN(v) *std::min_element(all(v))
#define MIN1(v) *std::min_element(all1(v))
#define MAX(v) *std::max_element(all(v))
#define MAX1(v) *std::max_element(all1(v))

constexpr i64 inf = 1E18, Md3 = 998244353, Md7 = 1e9 + 7;
constexpr double eps = 1E-9;


int main() {
	
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
		
	TESTS {
		int n;
		cin >> n;
		if(n % 2 == 0) {
			for(int i = 0; i < n - 1; i++) {
				cout << 1 << " ";
			}
			cout << 3 << "\n";
		} else {
			for(int i = 0; i < n - 1; i++) {
				cout << 1 << " ";
			}
			cout << n << "\n";
		}
	}

	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值