摘要: const int MOD = 1000000007; // 模数,通常是大素数 const int MAXN = 100000; // 设定最大值 long long fact[MAXN + 1]; // 阶乘数组 long long inv_fact[MAXN + 1]; // 逆阶乘数组 // 阅读全文
posted @ 2025-01-19 13:49 Qacter 阅读(64) 评论(0) 推荐(0)
摘要: class bint { vector<int> arr; // 存储数字,低位在前 int sign; // 符号位:1 表示正数,-1 表示负数 // 大整数加法 vector<int> add(const vector<int>& a, const vector<int>& b) const 阅读全文
posted @ 2025-01-16 15:13 Qacter 阅读(26) 评论(0) 推荐(0)
摘要: 格式说明符 在 std::format 中,你可以使用不同的格式说明符来控制如何格式化数据。常见的格式说明符包括: 整数格式: {:d}:以十进制格式输出整数。 {:x}:以十六进制格式输出整数(小写字母)。 {:X}:以十六进制格式输出整数(大写字母)。 {:b}:以二进制格式输出整数。 浮点数格 阅读全文
posted @ 2025-01-03 00:52 Qacter 阅读(40) 评论(0) 推荐(0)
摘要: // 将整数转换为二进制字符串 string intToBinary(int num) { if (num == 0) { return "0"; } string binary; while (num > 0) { binary = to_string(num & 1) + binary; // 阅读全文
posted @ 2025-01-02 23:49 Qacter 阅读(83) 评论(0) 推荐(0)
摘要: class Solution { public: vector<int> inorderTraversal(TreeNode* root) { vector<int> result; stack<TreeNode*> st; if (root != NULL) st.push(root); whil 阅读全文
posted @ 2024-12-20 10:39 Qacter 阅读(18) 评论(0) 推荐(0)
摘要: //颜色染色法 class Solution { public: bool canFinish(int numCourses, vector<vector<int>>& prerequisites) { vector<vector<int>>g(numCourses); for(auto&q:pre 阅读全文
posted @ 2024-12-17 22:42 Qacter 阅读(27) 评论(0) 推荐(0)
摘要: #include <iostream> using namespace std; // 快速幂(递归实现) long long fastPow(long long a, long long b) { if (b == 0) return 1; // 如果指数为0,任何数的0次方都为1 if (b % 阅读全文
posted @ 2024-12-14 00:36 Qacter 阅读(32) 评论(0) 推荐(0)
摘要: class Solution { public: int fourSumCount(vector<int>& nums1, vector<int>& nums2, vector<int>& nums3, vector<int>& nums4) { unordered_map<long,int>map 阅读全文
posted @ 2024-12-12 16:51 Qacter 阅读(12) 评论(0) 推荐(0)
摘要: 1:https://leetcode.cn/problems/maximum-value-of-an-ordered-triplet-ii/description/ class Solution { public: long long maximumTripletValue(vector& nums 阅读全文
posted @ 2024-12-12 16:12 Qacter 阅读(22) 评论(0) 推荐(0)
摘要: c语言常用语句: 1: while(getchar()!='\n'); //清除换行符(fgets必需) 2: int len =strlen(s); char ch=(char)malloc((len+1)*sizeof(char)); //开辟空间存储一段字符串(string.h) 3:fget 阅读全文
posted @ 2024-12-11 22:54 Qacter 阅读(20) 评论(0) 推荐(0)