摘要: 比赛链接 很久没有打比赛了,这次刚好看到了牛客的月赛,就做了一下。只会前四题,难度不大。 一、画牌河 思路: 直接按照题目要求输出一个矩阵即可,前x个元素为1,后面元素为0 代码: #include <iostream> #include <algorithm> using namespace st 阅读全文
posted @ 2023-02-24 22:20 hbhdhd 阅读(52) 评论(0) 推荐(0) 编辑
摘要: 题目:88. 合并两个有序数组 方法一: 直接暴力将两个数组合并,然后再排序。 class Solution { public void merge(int[] nums1, int m, int[] nums2, int n) { System.arraycopy(nums2, 0, nums1, 阅读全文
posted @ 2020-10-06 10:54 hbhdhd 阅读(794) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题意:就是求X的平方根。 思路: 方法一: 注意:指数函数和对数函数的参数和返回值均为浮点数,因此运算过程中会存在误差。因此在得到结果的整数部分ans 后,我们应当找出ans 与 ans+1 中哪一个是真正的答案。 代码: 1 class Solution { 2 public int m 阅读全文
posted @ 2020-09-30 21:18 hbhdhd 阅读(439) 评论(0) 推荐(0) 编辑
摘要: 这场比赛是建行赞助的,不得不说,国企就是有钱,已经霸占双周赛两三个月了,貌似还会继续,nb!!! 不多说了,看题: 1、5503. 所有奇数长度子数组的和 思路一:直接暴力,枚举所有奇数长度的子数组即可,用O(n^3)的时间复杂度也能过。 代码(copy大佬的C++码): 1 class Solut 阅读全文
posted @ 2020-09-20 16:57 hbhdhd 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 题目:https://leetcode-cn.com/problems/reverse-integer/ 题意:输入一个整数,输出它的反转数。 如321 >123 直接用数学方法转换。 tmp = x%10; ans = ans *10 + tmp; 每一步计算新值时判断ans是否溢出。 x是正数时 阅读全文
posted @ 2020-09-16 23:39 hbhdhd 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题目: 题解:很简单、经典的的一道快速幂的题 注意一下用LL型就ok。 代码: 1 #include <map> 2 #include <set> 3 #include <list> 4 #include <stack> 5 #include <queue> 6 #include <deq 阅读全文
posted @ 2020-06-25 11:14 hbhdhd 阅读(732) 评论(0) 推荐(0) 编辑
摘要: 题目: honoka最近在研究三角形计数问题。她认为,满足以下三个条件的三角形是“好三角形”。1.三角形的三个顶点均为格点,即横坐标和纵坐标均为整数。2.三角形的面积为 。3.三角形至少有一条边和 轴或 轴平行。honoka想知道,在平面中选取一个大小为 的矩形格点阵,可以找到多少个不同的“好三角形 阅读全文
posted @ 2020-02-08 23:48 hbhdhd 阅读(320) 评论(0) 推荐(0) 编辑
摘要: 链接:https://ac.nowcoder.com/acm/contest/3002/E rin最近喜欢上了数论。 然而数论实在太复杂了,她只能研究一些简单的问题。 这天,她在研究正整数因子个数的时候,想到了一个“快速迭代”算法。设 为 的因子个数,将 迭代下去,rin猜想任意正整数最终都会变成 阅读全文
posted @ 2020-02-06 12:50 hbhdhd 阅读(266) 评论(0) 推荐(0) 编辑
摘要: Description Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised 阅读全文
posted @ 2020-01-12 20:30 hbhdhd 阅读(209) 评论(0) 推荐(0) 编辑
摘要: Description The branch of mathematics called number theory is about properties of numbers. One of the areas that has captured the interest of number t 阅读全文
posted @ 2020-01-11 11:23 hbhdhd 阅读(184) 评论(0) 推荐(0) 编辑