数学
龍木
若人生为棋,我愿为卒,漫漫征途,谁曾见我后退半步
展开
-
力扣训练——位运算
本篇参照大佬博客练习题顺序,代码都是自打的,有些可能不是最优解。461. 汉明距离class Solution {public: int hammingDistance(int x, int y) { int ans=x^y,s=0; while(ans) { if(ans%2==1) s++; ans/=2; } return s;原创 2021-01-28 19:32:56 · 335 阅读 · 0 评论 -
力扣训练——数论
本篇参照大佬博客练习题顺序,代码都是自打的,有些可能不是最优解。目录204. 计数质数504. 七进制数405. 数字转换为十六进制数168. Excel表列名称172. 阶乘后的零67. 二进制求和415. 字符串相加462. 最少移动次数使数组元素相等 II169. 多数元素367. 有效的完全平方数326. 3的幂238. 除自身以外数组的乘积628. 三个数的最大乘积204. 计数质数class Solution {public:原创 2021-01-24 15:57:50 · 195 阅读 · 1 评论 -
D - Meaningless Sequence
https://codeforces.com/gym/102832/problem/DOnce there was a mathematician, who was obsessed with meaningless number sequences. Here is one of them.an={1,c⋅max0≤i<nan&i,n=0otherwise,an={1,n=0c⋅max0≤i<nan&i,otherwise,where&&...原创 2020-12-15 18:56:32 · 311 阅读 · 0 评论 -
D - Vacation
链接:https://vjudge.net/contest/381756#problem/DTom and Jerry are going on a vacation. They are now driving on a one-way road and several cars are in front of them. To be more specific, there arenncars in front of them. Theiith car has a length oflili,...原创 2020-07-08 09:53:54 · 261 阅读 · 0 评论 -
C. Pluses and Minuses
链接:https://codeforces.ml/contest/1373/problem/CYou are given a stringssconsisting only of characters+and-. You perform some process with this string. This process can be described by the following pseudocode:res = 0for init = 0 to inf cur = ...原创 2020-07-07 12:35:00 · 206 阅读 · 0 评论 -
C. A Cookie for You
链接:https://codeforces.ml/contest/1371/problem/CAnna is a girl so brave that she is loved by everyone in the city and citizens love her cookies. She is planning to hold a party with cookies. Now she hasaavanilla cookies andbbchocolate cookies for the ...原创 2020-07-06 09:18:48 · 195 阅读 · 0 评论 -
E. Modular Stability
链接:https://codeforces.ml/contest/1359/problem/EWe definexmodyxmodyas the remainder of division ofxxbyyy(%%operator in C++ or Java,modoperator in Pascal).Let's call an array of positive integers[a1,a2,…,ak][a1,a2,…,ak]stableif for every perm...原创 2020-05-29 12:31:16 · 294 阅读 · 1 评论 -
H 中位因数
链接:https://ac.nowcoder.com/acm/contest/5678/H来源:牛客网给出函数的定义如下:f(x)是所有能够整除 x 的数(包含 1 和 x )中的中位数向下取整的大小,g(x)=∑i=1xf(i)g(x)=\sum_{i = 1}^{x}{f(i)}g(x)=∑i=1xf(i)输入描述:输入包含多组数据,第一行为一个数字 T(1≤T≤10)T(1 \le T \le 10)T(1≤T≤10) ,表示测试数据组数。接下来是 T 组数据,每组数据为一.原创 2020-05-23 18:09:35 · 355 阅读 · 0 评论 -
C1. Simple Polygon Embedding
链接:https://codeforces.ml/contest/1354/problem/C1The statement of this problem is the same as the statement of problem C2. The only difference is that, in problem C1,nnis always even, and in C2,nnis always odd.You are given a regular polygon with2⋅...原创 2020-05-18 18:13:27 · 187 阅读 · 0 评论 -
C2. Not So Simple Polygon Embedding
链接:https://codeforces.ml/contest/1354/problem/C2The statement of this problem is the same as the statement of problem C1. The only difference is that, in problem C1,nnis always even, and in C2,nnis always odd.You are given a regular polygon with2⋅...原创 2020-05-18 18:12:24 · 373 阅读 · 0 评论 -
C. Count Triangles
链接:https://codeforces.com/contest/1355/problem/CLike any unknown mathematician, Yuri has favourite numbers:AA,BB,CC, andDD, whereA≤B≤C≤DA≤B≤C≤D. Yuri also likes triangles and once he thought: how many non-degenerate triangles with integer sidesxx,...原创 2020-05-17 11:43:25 · 402 阅读 · 0 评论 -
A 像鱼
给你一个边长为 n 的用硬币摆成的实心三角形,请问把他倒过来最少需要多少步?例子:这是一个边长为3的硬币三角形只要移动边上的两个硬币,就可以把它到过来(注意是倒过来,不是旋转角度),变成这样:聪明的 Prev1ous秒切了这道题,于是他希望来考考你Prev1ous 经过计算后发现,由于答案实在是太大了,所以他只关心答案对23333333333333333取膜的结果,顺...原创 2020-05-03 12:34:59 · 285 阅读 · 0 评论 -
F. Kate and imperfection
链接:https://codeforc.es/contest/1333/problem/FKate has a setSSofnnintegers{1,…,n}{1,…,n}.She thinks thatimperfectionof a subsetM⊆SM⊆Sis equal to themaximumofgcd(a,b)gcd(a,b)over all pa...原创 2020-04-09 10:12:49 · 303 阅读 · 0 评论 -
C 装备合成
链接:https://ac.nowcoder.com/acm/contest/4743/C牛牛有{x}x件材料{a}a和{y}y件材料{b}b,用{2}2件材料{a}a和{3}3件材料{b}b可以合成一件装备,用{4}4件材料{a}a和{1}1件材料{b}b也可以合成一件装备。牛牛想要最大化合成的装备的数量,于是牛牛找来了你帮忙。输入描述:输入包含{t}t组数据第一行一个整数{t}...原创 2020-03-14 11:32:51 · 561 阅读 · 0 评论 -
D. Count the Arrays
链接:https://codeforces.ml/contest/1312/problem/DYour task is to calculate the number of arrays such that:each array containsnnelements; each element is an integer from11tomm; for each array,...原创 2020-03-10 14:00:50 · 520 阅读 · 0 评论 -
C. Adding Powers
链接:https://codeforces.ml/contest/1312/problem/CSuppose you are performing the following algorithm. There is an arrayv1,v2,…,vnv1,v2,…,vnfilled with zeroes at start. The following operation is appl...原创 2020-03-10 13:36:13 · 336 阅读 · 0 评论 -
C. Kuroni and Impossible Calculation
链接:https://codeforces.ml/contest/1305/problem/CTo become the king of Codeforces, Kuroni has to solve the following problem.He is givennnnumbersa1,a2,…,ana1,a2,…,an. Help Kuroni to calculate∏1≤...原创 2020-03-04 08:23:41 · 430 阅读 · 0 评论 -
D. Minimum Triangulation
链接:https://codeforces.ml/contest/1140/problem/DYou are given a regular polygon withnnvertices labeled from11tonnin counter-clockwise order. The triangulation of a given polygon is a set of tri...原创 2020-02-26 17:37:27 · 431 阅读 · 0 评论 -
E 立方数
链接:https://ac.nowcoder.com/acm/contest/3007/E对于给定的正整数 N,求最大的正整数 A,使得存在正整数 B,满足 A3B=N输入包含 T 组数据,1≤T≤10,000;1≤N≤1018输入描述:第一行数字 T 表示数据组数接下来一行,T 个正整数 N输出描述:T 行,每行一个数字表示答案示例1输入...原创 2020-02-16 16:19:01 · 408 阅读 · 0 评论 -
D 重排列
一个序列的重排列是指对这个序列中的元素进行若干次(包括0次)交换操作后得到的新序列在本题中,序列中可能出现重复的数字,他们被视作不同的元素例如,序列1 1的重排列有两种现在有两个长度为 N 的非负整数序列 A 和 B,问有多少种 A 的重排列满足对于所有的 1≤i≤N,有Ai≤Bi由于答案可能很大,你只需要输出答案对1e9+7取模的结果输入描述:输入第一行,包含一...原创 2020-02-16 14:44:39 · 300 阅读 · 2 评论 -
D 牛牛与牛妹的约会
链接:https://ac.nowcoder.com/acm/contest/3006/D牛牛在辛苦的一天的比赛之后,要去找牛妹玩,其实牛妹那天也在比赛。他为了找到牛妹,要尽快的从自己的比赛地到她的比赛地。还记得吗,比赛地都是只在xx轴上的,所以两个人的坐标都满足y=0y=0。牛牛除了可以以11单位距离/单位时间的速度移动任意时间以外,还可以花费11单位时间进行闪现。每次闪现时,如果当前他...原创 2020-02-14 05:49:33 · 390 阅读 · 0 评论 -
B. Pasha and Tea
链接:https://codeforces.com/contest/557/problem/BPasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity ofwmilliliters and2ntea cups, each c...原创 2020-02-07 19:35:02 · 313 阅读 · 0 评论 -
E 做计数
链接:https://ac.nowcoder.com/acm/contest/3003/E题目描述这一天,牛牛与 牛魔王相遇了――然而这并不在 牛牛期望之中。牛魔王不出意料又给 牛牛一道看似很难的题目:求有多少个不同的正整数三元组\text{}(i,j,k)(i,j,k)满足\sqrt i+\sqrt j=\sqrt ki+j=k,且i\times j\leq ni×j...原创 2020-02-06 22:28:03 · 128 阅读 · 0 评论 -
D. Taxes
链接:https://codeforces.com/problemset/problem/735/DMr. Funt now lives in a country with a very specific tax laws. The total income of mr. Funt during this year is equal ton(n ≥ 2) burles and the am...原创 2020-02-05 18:55:41 · 270 阅读 · 0 评论 -
C. Pythagorean Triples
链接:https://codeforces.com/problemset/problem/707/CKatya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of posit...原创 2020-02-01 14:15:50 · 320 阅读 · 2 评论 -
D. Almost All Divisors
链接:https://codeforces.com/problemset/problem/1165/DWe guessed some integer numberxx. You are given a list ofalmost allits divisors.Almost allmeans that there areall divisors except11andxxin...原创 2020-01-31 16:34:11 · 183 阅读 · 0 评论 -
D. Same GCDs
链接:https://codeforces.com/contest/1295/problem/DYou are given two integersaaandmm. Calculate the number of integersxxsuch that0≤x<m0≤x<mandgcd(a,m)=gcd(a+x,m)gcd(a,m)=gcd(a+x,m).Note...原创 2020-01-30 18:13:09 · 573 阅读 · 0 评论 -
D. Fun with Integers
链接:https://codeforces.com/group/nhsfFrN6WT/contest/266629/problem/DYou are given a positive integernngreater or equal to22. For every pair of integersaaandbb(2≤|a|,|b|≤n2≤|a|,|b|≤n), you can ...原创 2020-01-22 18:32:39 · 270 阅读 · 0 评论 -
C. Banh-mi
链接:https://codeforces.com/group/nhsfFrN6WT/contest/266629/problem/CJATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as ...原创 2020-01-22 18:31:15 · 464 阅读 · 0 评论 -
D. Aroma's Search
链接:https://codeforces.com/contest/1293/problem/DTHE SxPLAY & KIVΛ - 漂流KIVΛ & Nikki Simmons - PerspectivesWith a new body, our idol Aroma White (or should we call her Kaori Minamiya?) beg...原创 2020-01-20 10:49:59 · 483 阅读 · 3 评论 -
C. Fly
链接:https://codeforces.com/group/nhsfFrN6WT/contest/266292/problem/CNatasha is going to fly on a rocket to Mars and return to Earth. Also, on the way to Mars, she will land onn−2n−2intermediate pla...原创 2020-01-19 16:13:07 · 258 阅读 · 0 评论 -
A. Plate Game
链接:https://codeforces.com/problemset/problem/197/AYou've got a rectangular table with lengthaand widthband the infinite number of plates of radiusr. Two players play the following game: they ta...原创 2020-01-18 18:51:53 · 537 阅读 · 0 评论 -
A. The Meaningless Game
链接:https://codeforces.com/contest/833/problem/A?csrf_token=862e52f95602b95868e7c73a958718d7Slastyona and her loyal dog Pushok are playing a meaninglessgamethat is indeed very interesting.Thegam...原创 2020-01-18 14:27:31 · 137 阅读 · 0 评论 -
A. 24 Game
链接:https://codeforces.com/problemset/problem/468/ALittle X used to play a card game called "24 Game", but recently he has found it too easy. So he invented a new game.Initially you have a sequence...原创 2020-01-18 13:06:31 · 164 阅读 · 0 评论 -
A. Gerald's Hexagon
链接:https://codeforces.com/problemset/problem/559/AGerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to. Then he measured the length ...原创 2020-01-17 14:33:28 · 238 阅读 · 0 评论 -
D. 1-2-K Game
链接:https://codeforces.com/contest/1194/problem/DAlice and Bob play a game. There is a paper strip which is divided inton + 1cells numbered from left to right starting from0. There is a chip place...原创 2020-01-17 13:56:51 · 164 阅读 · 0 评论 -
A. Alice and Bob
链接:https://codeforces.com/contest/346/problem/AIt is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of...原创 2020-01-17 13:25:36 · 342 阅读 · 0 评论 -
A. Vasya and Petya's Game
链接:https://codeforces.com/problemset/problem/576/AVasya and Petya are playing a simple game. Vasya thought of numberxbetween1andn, and Petya tries to guess the number.Petya can ask questions ...原创 2020-01-17 11:04:10 · 283 阅读 · 0 评论 -
The GCD of Fibonacci Numbers
链接:https://ac.nowcoder.com/acm/contest/3674/AThe Fibonacci sequence is the sequence of numbers such that every element is equal to the sum of the two previous elements, except for the first two elem...原创 2020-01-12 10:09:37 · 218 阅读 · 0 评论 -
B. A and B
链接:https://codeforces.com/problemset/problem/1278/BYou are given two integersaaandbb. You can perform a sequence of operations: during the first operation you choose one of these numbers and incr...原创 2020-01-09 13:19:31 · 409 阅读 · 0 评论