- 博客(22)
- 收藏
- 关注
原创 A-Ares, Toilet Ares 2021牛客多校8
链接:https://ac.nowcoder.com/acm/contest/11259/A题目描述Ares is the Greek god of courage and war. He is one of the Twelve Olympians and the son of Zeus and Hera. In Greek literature, he often represents the physical or violent and untamed aspect of war and i
2021-08-10 19:01:01 253
原创 Acwing 3792.质数问题
题目描述:给定两个整数 n 和 k,请你判断在 [2,n] 的范围内是否存在不少于 k 个质数,满足可以表示为两个相邻质数与 1 的和。例如,19 满足条件,因为 19=7+11+1。输入格式第一行包含整数 T,表示共有 T 组测试数据。每组数据占一行,包含两个整数 n 和 k。输出格式每组数据输出占一行,如果存在不少于 k 个质数满足条件则输出 YES,否则输出 NO。数据范围1≤T≤30, 2≤n≤1000, 0≤k≤1000输入样例:527 245
2021-08-08 18:02:13 137
原创 Acwing 3793.最大分数
题目描述:给定 nn 个整数 a1,a2,…,an。请你从中选取最多不超过 m 个数(也可以什么都不选)。选取正数将会扣除相应值的分数,选取负数将会得到相应值的绝对值的分数,选取 0 不得分也不扣分。请计算可以获得的最大分数。输入格式第一行包含整数 T,表示共有 T 组测试数据。每组数据第一行包含两个整数 n,m。第二行包含 n 个整数 a1,a2,…,an。输出格式每组数据输出一行结果,表示最大分数。数据范围1≤T≤20, 1≤m≤n≤100, −1000≤
2021-08-08 17:52:17 139
原创 F-Hamburger Steak 2021牛客多校6
链接:https://ac.nowcoder.com/acm/contest/11257/F题目描述:Riko is ready to cook hamburger steaks. There are m pans and n hamburger steaks that need to be fried. The i-th hamburger steak needs to be fried for ti (which is a positive integer) minutes. Riko can
2021-08-08 17:41:45 174
原创 I-xay loves or - 2021牛客多校7(位运算)
链接:https://ac.nowcoder.com/acm/contest/11258/I题目描述:xay loves or. He gives you x and s, you need to calculate how many positive integer y satisfy x or y = s .输入描述:The first line contains two positive integers x and s .It's guaranteed that 1≤x,s&
2021-08-08 16:17:00 121
原创 枚举n以内的素数(枚举+埃氏筛+线性筛+奇数筛)
统计[2,n)区间内的素数个数。1.枚举[2,n) 从2开始遍历,一个一个数去判断是否是素数。#include <bits/stdc++.h> using namespace std;const int N = 1e5+5;int prime[N]; //prime数组存放素数 int isPrime(int n) //判断n是否为素数,是素数返回1,不是返回0{ for(int i=2;i*i<=n;i++){ if(n % i == 0) return
2021-08-06 15:37:38 1824
原创 LeetCode - 零矩阵
题目来源:https://leetcode-cn.com/problems/zero-matrix-lcci/题目描述:编写一种算法,若M × N矩阵中某个元素为0,则将其所在的行与列清零。示例 1:输入:[[1,1,1],[1,0,1],[1,1,1]]输出:[[1,0,1],[0,0,0],[1,0,1]]示例 2:输入:[[0,1,2,0],[3,4,5,2],[1,3,1,5]]输出:[[0,0
2021-08-01 18:23:31 131
原创 D - Querying Multiset - AtCoder Beginner Contest 212(优先队列)
题目描述:Takahashi has many balls, on which nothing is written, and one bag. Initially, the bag is empty. Takahashi will do Q operations, each of which is of one of the following three types. Type 1: Write an integer Xi on a blank ball and put it in the b
2021-08-01 18:12:31 160
原创 C - Min Difference - AtCoder Beginner 212(排序双指针)
题目描述:You are given two sequences: A=(A1,A2,…,AN) consisting of N positive integers, and B=(B1,…,BM) consisting of M positive integers.Find the minimum difference of an element of A and an element of B, that is, min1≤i≤Nmin1≤j≤M|Ai−Bj|.数据范围: 1≤N,M≤
2021-08-01 17:48:07 217
原创 LeetCode 旋转矩阵/旋转图像(数组)
题目来源:面试题 01.07. 旋转矩阵 https://leetcode-cn.com/problems/rotate-matrix-lcci/48.旋转图像 https://leetcode-cn.com/problems/rotate-image/题目描述:给你一幅由 N × N 矩阵表示的图像,其中每个像素的大小为 4 字节。请你设计一种算法,将图像旋转 90 度。不占用额外内存空间能否做到?示例 1:给定 matrix =[[1,2,3],...
2021-08-01 17:21:16 319
原创 Acwing 3782.点(数学题)
题目描述:给定一个平面上的 N 个点,请你计算所有点对之间距离的平方和。输入格式第一行包含整数 N,表示点的个数。接下来 N 行,每行包含两个整数 X,Y,表示一个点的横纵坐标。注意,不保证所有点的位置各不相同。输出格式输出所有点对之间距离的平方和。数据范围1≤N≤10^5, −10000≤X,Y≤10000。输入样例:4 1 1 -1 -1 1 -1 -1 1输出样例:32思路:两点(x1,x2)之间的距离的平方为:我们可以发现,
2021-07-28 11:22:25 205
原创 C - chokudai AtCoder Beginner 211(字符串+动态规划DP)
题目描述:You are given a string S. How many ways are there to choose and underline eight of its characters so that those characters read c, h, o, k, u, d, a, i from left to right? Since the count can be enormous, print it modulo (10^9+7).数据范围: 8≤|S|≤10^
2021-07-25 22:52:53 502 3
原创 E.Math - 2021牛客暑期多校3
链接:https://ac.nowcoder.com/acm/contest/11254/E 来源:牛客网题目描述Given n, count the number of pairs of positive integers (x, y), such that xy+1∣x^2+y^2,1≤x≤y≤n. There're t test cases in total.输入描述:First line contains an integer t(1≤t≤10^5). Next t lines e
2021-07-25 21:43:40 256
原创 A Retribution! - 2019 ECNA(贪心+结构体排序)
链接:https://ac.nowcoder.com/acm/contest/18453/A 来源:牛客网题目描述The coaches in a certain regional are fed up with the judges. During the last contest over 90% of the teams failed to solve a single problem—in fact, even half the judges found the problems too h
2021-07-23 10:32:51 310
原创 Acwing 3774.亮灯时长
题目描述:自习室内有一个智能灯。在 0 时刻,管理员会将打开电闸,并将灯点亮。在 M 时刻,管理员会直接拉下电闸,此时,如果灯处于点亮状态,则会因为断电而熄灭。在 0∼M 之间有 n 个不同时刻,不妨用 a1,a2,…,an 表示,其中 0<a1<a2<…<an<M。在这 n 个时刻中的每个时刻,管理员都会拨动一次智能灯的开关,使灯的状态切换(亮变灭、灭变亮)。现在,你可以最多额外指定一个时刻(也可以不指定),让管理员在此时刻也拨动开关一次。注意选定的时
2021-07-22 09:47:07 200
原创 K-Stack 2021牛客多校2
链接:https://ac.nowcoder.com/acm/contest/11253/K 来源:牛客网题目描述ZYT had a magic permutation a1,a2,⋯ ,an and he constructed a sequence b1,b2,⋯bn by the following pseudo code:Stk is an empty stackfor i = 1 to n : while ( Stk is not empty ) and ( Stk..
2021-07-20 10:45:21 187
原创 C. Pursuit Cf #733 (Div.1+Div. 2)
https://codeforces.com/contest/1530/problem/C题目描述:You and your friend Ilya are participating in an individual programming contest consisting of multiple stages. A contestant can get between 0 and 100 points, inclusive, for each stage, independently of
2021-07-18 11:32:18 332
原创 C - Colorful Candies AtCoder Beginner Contest 210
https://atcoder.jp/contests/abc210/tasks/abc210_c题目描述:There are N candies arranged in a row from left to right. Each of these candies has one color that is one of the 10^9 colors called Color 1, Color 2, ……, and Color 10^9. For each i=1,2,…,N, the colo
2021-07-18 11:31:25 284
原创 A-Alice and Bob 2021牛客多校1
链接:https://ac.nowcoder.com/acm/contest/11166/A 来源:牛客网题目描述Alice and Bob like playing games. There are two piles of stones with numbers n and m. Alice and Bob take turns to operate, each operation can take away k(k>0) stones from one pile and take awa
2021-07-18 11:29:37 903
原创 A- 选数
题目来源:洛谷P1036https://www.luogu.com.cn/problem/P1036题目描述已知 n 个整数 x1,x2,…,xn 以及11个整数k(k<n)。从n个整数中任选k个整数相加,可分别得到一系列的和。例如当n=4,k=3,4个整数分别为3,7,12,19时,可得全部的组合与它们的和为:3+7+12=223+7+19=297+12+19=383+12+19=34。现在,要求你计算出和为素数共有多少种。例如上例,只有一种的和为素数:3+7+19=
2021-06-29 14:37:03 168 1
原创 灯泡问题-数学分析题
灯泡问题题目来源:leetcode 319 https://leetcode-cn.com/problems/bulb-switcher/题目描述初始时有 n 个灯泡处于关闭状态。对某个灯泡切换开关意味着:如果灯泡状态为关闭,那该灯泡就会被开启;而灯泡状态为开启,那该灯泡就会被关闭。第 1 轮,每个灯泡切换一次开关。即,打开所有的灯泡。第 2 轮,每两个灯泡切换一次开关。 即,每两个灯泡关闭一个。第 3 轮,每三个灯泡切换一次开关。第 i 轮,每 i 个灯泡切换一次开关。 而
2021-06-15 23:53:02 1342 1
原创 A. Omkar and Bad Story-cf#724
A. Omkar and Bad Story题目来源:Codeforces Round #724(Div.2) https://codeforces.com/contest/1536/problem/Atime limit per test:2 secondsmemory limit per test:256 megabytesOmkar has received a message from Anton saying "Your story for problem A is c..
2021-06-14 23:05:20 502
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人