
算法-题
文章平均质量分 75
记录做题思路,也作笔记,以C++为主。
Att1cusss
被子里面喊冲锋!!!
展开
-
C. Sum of Cubes
题目来源一、题目You are given a positive integer x. Check whether the number x is representable as the sum of the cubes of two positive integers.Formally, you need to check if there are two integers a and b (1≤a,b) such that a^3 + b^3=x.For example, if x=35,原创 2021-02-17 12:58:19 · 602 阅读 · 0 评论 -
D. Permutation Transformation
题目来源一、题目给定一个数组,按如下规律建树:最大元素为根节点,最大元素左边的元素中,最大元素为左子树根节点,最大元素右边的元素中,最大元素为右子树根节点。根节点深度为0,给定数组a,输出每个元素在树中的深度。二、输入The first line contains one integer t (1≤t≤100) — the number of test cases. Then t test cases follow.The first line of each test case cont原创 2021-02-17 12:46:56 · 410 阅读 · 2 评论 -
D. Pythagorean Triples
题目来源一、题目A Pythagorean triple is a triple of integer numbers (a,b,c) such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to a, b and c, respectively. An example of the Pyt原创 2021-02-16 13:53:22 · 830 阅读 · 0 评论 -
C. Minimum Ties
题目来源一、题目A big football championship will occur soon! n teams will compete in it, and each pair of teams will play exactly one game against each other.There are two possible outcomes of a game:the game may result in a tie, then both teams get 1 point;原创 2021-02-16 11:24:01 · 378 阅读 · 0 评论 -
B. Cat Cycle
题目来源一、题目Suppose you are living with two cats: A and B. There are n napping spots where both cats usually sleep.Your cats like to sleep and also like all these spots, so they change napping spot each hour cyclically:Cat A changes its napping place in o原创 2021-02-16 10:32:20 · 794 阅读 · 2 评论 -
B - -- - B
来源:https://atcoder.jp/contests/arc112/tasks/arc112_b一、题目Snuke has come to Seisu-ya (integer shop) with an integerB in his hand. In Seiyu-ya, you can exchange your integer for another integer by paying money.More specifically, you can use the following原创 2021-02-13 22:57:55 · 742 阅读 · 0 评论 -
Bowls and Dishes
来源:https://atcoder.jp/contests/abc190/tasks/abc190_c一、题目N个盘子,M个条件,当且仅当Ai和Bi盘子上有球时,条件i被满足。有K个顾客,每个顾客会在盘子Ci或者Di上放一个球。问最多有多少条件被满足?二、输入N MA1 B1...AM BMKC1 D1...Ck Dk三、输出输出答案四、样例input:4 41 21 32 43 431 21 32 3output:2inpu原创 2021-02-05 10:42:51 · 321 阅读 · 0 评论 -
ROADS
来源:http://bailian.openjudge.cn/practice/1724/一、题目N cities named with numbers 1 … N are connected with one-way roads. Each road has two parameters associated with it : the road length and the toll that needs to be paid for the road (expressed in the numb原创 2021-02-04 21:24:56 · 98 阅读 · 0 评论 -
Inflation
一、题目You have a statistic of price changes for one product represented as an array of n positive integers p0,p1,…,pn−1, where p0 is the initial price of the product and pi is how the price was increased during the i-th month.Using these price changes you原创 2021-01-30 17:38:47 · 404 阅读 · 0 评论 -
Nezzar and Lucky Number
一、题目Nezzar’s favorite digit among 1,…,9 is d. He calls a positive integer lucky if d occurs at least once in its decimal representation.Given q integers a1,a2,…,aq, for each 1≤i≤q Nezzar would like to know if ai can be equal to a sum of several (one or原创 2021-01-29 17:31:33 · 618 阅读 · 0 评论 -
Advertising Agency
一、题目Masha works in an advertising agency. In order to promote the new brand, she wants to conclude contracts with some bloggers. In total, Masha has connections of n different bloggers. Blogger numbered i has ai followers.Since Masha has a limited budge原创 2021-01-27 10:41:48 · 334 阅读 · 0 评论 -
Ball in Berland
一、题目At the school where Vasya is studying, preparations are underway for the graduation ceremony. One of the planned performances is a ball, which will be attended by pairs of boys and girls.Each class must present two couples to the ball. In Vasya’s cl原创 2021-01-27 10:21:28 · 374 阅读 · 0 评论 -
D - Logical Expression
题目来源:https://atcoder.jp/一、题目大意给定N个字符串S1 ,…,Sn ,每个字符串内容为 AND 或 OR 。找到使yn为1的序列(x0 ,…,xn)的数量。1.y0 = x02.对于i >= 1 ,当Si 为AND时,yi =y i-1 ∧xi ;当Si 为OR时,yi =y i-1 ∨xi二、输入第一行,一个正整数 N 。后面N行为S1 …Sn三、输出满足条件的序列数量四、样例样例一input:2ANDORou原创 2021-01-24 14:33:39 · 312 阅读 · 0 评论 -
利用位运算枚举 费解的开关
费解的开关一、题目你玩过“拉灯”游戏吗?25盏灯排成一个5x5的方形。每一个灯都有一个开关,游戏者可以改变它的状态。每一步,游戏者可以改变某一个灯的状态。游戏者改变一个灯的状态会产生连锁反应:和这个灯上下左右相邻的灯也要相应地改变其状态。我们用数字“1”表示一盏开着的灯,用数字“0”表示关着的灯。下面这种状态1011101101101111000011011在改变了最左上角的灯的状态后将变成:0111111101101111000011011再改变它正中间的灯后状态将变成:原创 2021-01-23 17:59:45 · 220 阅读 · 2 评论 -
签订协议
题目来源:牛客网https://ac.nowcoder.com/一、题目一共有n个国家来到了停战点,在协议停战签订的会场里,环形排布着n个位置, 位置从1开始编号,一直到n号,每个位置上有一个国家。签订停战协议的仪式开始了,停战协议书从1号位置开始传递,一直传递到n号位置, 传到n号时,n号会再传回给1号,从而开始新的一轮传递。 停战协议签订的顺序必须按照国家的战力来排序,战力最高的最先签订停战协议。也就是说,如果停战协议轮到了某个国家,但该国家并不是在场还未签订协议的国家中战力最强的,那么他这轮原创 2021-01-22 22:53:05 · 132 阅读 · 0 评论 -
照看小猫
一、题目在一个风和日丽的午后,少佐给薇尔莉特伊芙嘉登安排了一个任务。任务大致是这样的,接下来的一周,薇尔莉特需要照顾 N 只小猫咪。为了方便管理这N 只猫咪,薇尔莉特准备给每只猫咪取一个独一无二的名字。取名字要征求猫咪本咪的同意才可以。但这些猫咪都非常有个性,绝不接受很长的名字。现给出每只猫咪所能容忍名字的长度上限。请你为所有猫咪取名字,请问共有多少种不同的方案。名字仅包含小写英文字母。结果可能非常大,所以请将结果对 77797 取模如果无方案,请输出 -1二、输入第一行,一个正整原创 2021-01-22 22:45:13 · 286 阅读 · 0 评论 -
Different Divisors
Positive integer x is called divisor of positive integer y, if y is divisible by x without remainder. For example...原创 2021-01-20 14:21:57 · 1527 阅读 · 7 评论 -
棋盘问题
在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。原创 2021-01-17 19:30:43 · 622 阅读 · 0 评论