<svg style="display: none;" xmlns="http://www.w3.org/2000/sv
题干: You are given a chessboard of size n×nn×n. It is filled with numbers from 11 to n2n2 in the following way: the first ⌈n22⌉⌈n22⌉ numbers from 11 t
链接:https://ac.nowcoder.com/acm/contest/940/G 来源:牛客网 题目描述 kotori最近喜欢上了lovelive这个游戏,因为她发现自己居然也是里面的一个人物。 lovelive有个抽卡系统。共有R、SR、SSR、UR四个稀有度,每次单抽对应稀有度的概率
题干: A prefix of a string is a substring starting at the beginning of the given string. The prefixes of "carbon" are: "c", "c
链接:https://ac.nowcoder.com/acm/contest/940/F 来源:牛客网 题目描述 kotori最近在研究n皇后的问题。 所谓n皇后问题是这样的:一个n*n的地图,上面一共放n个皇后,保证任意两个皇后都不能互相攻击(每个皇后可以攻击同一行、同一列以及同一45度角斜线
http://codeforces.com/problemset/problem/402/E You have matrix a of size n × n. Let's number the rows of the matrix from 1 to n from top to bottom, l
题干: Ignatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀). Input 输入数据的第一部分是一张单词表,每行一个单词,单词的长度不超过10,它们代表的是老师交给Ignati
链接:https://ac.nowcoder.com/acm/contest/940/E 来源:牛客网 题目描述 kotori拿到了一些正整数。她决定从每个正整数取出一个素因子。但是,kotori有强迫症,她不允许两个不同的正整数取出相同的素因子。 她想知道,最终所有取出的数的和的最小值是多少?
http://codeforces.com/problemset/problem/401/D Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To mak
链接:https://ac.nowcoder.com/acm/contest/940/D 来源:牛客网 题目描述 kotori在一个n*m迷宫里,迷宫的最外层被岩浆淹没,无法涉足,迷宫内有k个出口。kotori只能上下左右四个方向移动。她想知道有多少出口是她能到达的,最近的出口离她有多远? 输入
题干: lily的好朋友xiaoou333最近很空,他想了一件没有什么意义的事情,就是统计一篇文章里不同单词的总数。下面你的任务是帮助xiaoou333解决这个问题。 Input 有多组数据,每组一行,每组就是一篇小文章。每篇小文章都是由小写字母和空格组成,没有标点符号,遇到#时表示输入结束。
链接:https://ac.nowcoder.com/acm/contest/940/C 来源:牛客网 题目描述 kotori和一些偶像们围成一圈,一共有n个偶像(包括kotori自己),她们的序号顺时针从1到n。现在她们从1号开始进行顺时针报数:1,2,1,2,1…… 每个报到2的人出列。直到
题干: Problem Statement Mr. Infinity has a string S consisting of digits from 1 to 9. Each time the date changes, this string changes as follows: E
链接:https://ac.nowcoder.com/acm/contest/940/B 来源:牛客网 题目描述 kotori最近迷上了摆气球的游戏。她一共有n种气球,每种气球有无数个。她要拿出若干个气球摆成一排。 但是,由于气球被施放了魔法,同样种类的气球如果相邻会发生爆炸,因此若两个相邻的气
题干: Given A,B,C, You should quickly calculate the result of A^B mod C. (1<=A,C<=1000000000,1<=B<=10^1000000). Input There are multiply
问题 G: 天神下凡 时间限制: 1 Sec 内存限制: 128 MB 题目描述 Czy找到宝藏获得屠龙宝刀和神秘秘籍!现在他要去找经常ntr他的Jmars报仇…… Czy学会了一招“堕天一击”,他对一个地点发动堕天一击,地面上就会留下一个很大的圆坑。圆坑的周围一圈能量太过庞大,因此无法通过
链接:https://ac.nowcoder.com/acm/contest/940/A 来源:牛客网 题目描述 kotori共有n块糖果,每块糖果的初始状态是分散的,她想把这些糖果聚在一堆。但她每次只能把两堆糖果合并成一堆。 已知把两堆数量为a和b的糖果聚在一堆的代价是|a-b|。 koto
题干: The most exciting space discovery occurred at the end of the 20th century. In 1999, scientists traced down an ant-like creature in the planet Y19
问题 I: 斗地主 时间限制: 1 Sec 内存限制: 128 MB 题目描述 牛牛最近迷上了一种叫斗地主的扑克游戏。斗地主是一种使用黑桃、红心、梅花、方片的A到K加上大小王的共54张牌来进行的扑克牌游戏。在斗地主中,牌的大小关系根据牌的数码表示如下:3<4<5<6<
题干: You are to find the length of the shortest path through a chamber containing obstructing walls. The chamber will always have sides at x = 0, x =
A Rubbish 链接:https://ac.nowcoder.com/acm/contest/912/A 来源:牛客网 题目描述 垃圾小x经常在机房丢垃圾,比如奶茶杯子、用过的湿巾纸、吃完的零食包装等。 可是训练的桌子上放了电脑,实在放不下小x丢的垃圾了。因此,大家搬了一张专门丢垃圾的桌子
/**/ #include <cstdio> #include <cstring> #include <cmath> #include <cctype> #include <iostream> #include <algorithm&
题干: In how many ways can you tile a 3xn rectangle with 2x1 dominoes? Here is a sample tiling of a 3x12 rectangle. Input Input consists of sever
链接:https://ac.nowcoder.com/acm/contest/911/A 来源:牛客网 A Good 的集合 题目描述 平面上给 n(3≤n≤1000) 个点,保证不存在 3 点共线,保证这些点两两不重合,对于一个点集 S ,如果从 S 中任意选出三个不同的点,构成的三角形重心都
/**/ #include <cstdio> #include <cstring> #include <cmath> #include <cctype> #include <iostream> #include <algorithm&
题干: 给出长度为n的序列a, 求有多少对数对 (i, j) (1 <= i < j <= n) 满足 ai + aj 为完全平方数。 输入描述: 第一行一个整数 n (1 <= n <= 105) 第二行 n 个整数 ai (1 <= ai <=
/**/ #include <cstdio> #include <cstring> #include <cmath> #include <cctype> #include <iostream> #include <algorithm&
题干: 描述 对一个给定的矩形,将其划分成尽可能少的正方形,输出正方形的最少个数。例如,如下图所示的情况,则输入为3和4,输出为4。 输入 输入两个整数中间用空格分开。 输出 输出最少分割成的正方形的个数。 输入样例 1 3 4 输出样例 1 4 解题报
题干: 描述 输入 输入包含多组数据,第一行T表示数据组数接下来每行六个整数n,m,x1,y1,x2,y2(分别表示n,m,起点坐标,终点坐标) 输出 输出T行,表示起点到终点的路径数 输入样例 1 1 30 30 1 15 3 15 输出样例 1 2
题干: You are given an infinite checkered field. You should get from a square (x1; y1) to a square (x2; y2). Using the shortest path is not necessary.
题干: Description Farmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needs N (1 ≤ N ≤
题目简叙: 请你求出从1到n的最短路径,其中最短路径☞这条路经过的边的权值的乘积。 题目分析: 很显然,这也是一道经典的单元最短路问题,首先我们可以考虑使用Floyd,显然,这是一个比较无脑简单的最短路算法,而且包治负边权等等。但是时间复杂度太高,可达
http://codeforces.com/contest/723/problem/F You are given an undirected connected graph consisting of n vertices and m edges. There are no loops and
题干: 一整数数列a1, a2, ... , an(有正有负),以及另一个整数k,求一个区间i,ji,j,(1 <= i <= j <= n),使得aii + ... + ajj = k。 Input 第1行:2个数N,K。N为数列的长度。K为需要求的和。(2 <= N
Description 公元20XX年,人类与外星人之间的大战终于爆发。 现有一个人类军团,由n名士兵组成,第i个士兵的战斗力值对应一个非负整数ai (1 \leq i \leq n1≤i≤n)。 有一天,某个战力爆表的外星人NaN单独向地球人宣战,已知它的战力值为k (1 \leq k \l
<svg style="display: none;" xmlns="http://www.w3.org/2000/sv
题干: Given n segments in the two dimensional space, write a program, which determines if there exists a line such that after projecting these segments
文章目录 一小时学会如何生成词云 (python 0 基础) 1 安装python 2 打开命令行 3 安装库 4 打开编辑器 一小时学会如何生成词云 (python 0 基础) 1 安装python 选择最新版,点击download,双击安
题干: We all know that a pair of distinct points on a plane defines a line and that a pair of lines on a plane will intersect in one of three ways: 1)
题干: Mom and dad have a problem: their child, Reza, never puts his toys away when he is finished playing with them. They gave Reza a rectangular bo
安装词云的时候显示缺少库依赖,安装相应的库即可 pip install matplotlib 可能会失败,还是老办法,多试几次
题干: This problem's actual name, "Lexicographically Largest Palindromic Subsequence" is too long to fit into the page headline. You are giv
对函数的引用: #include<iostream> #include<algorithm> #include<queue> #include<map> #include<vector> #include<set> #inc
'r' 只读模式,默认值,如果文件不存在,返回FileNotFoundError 'w' 覆盖写模式,文件不存在则创建,存在则完全覆盖 'x' 创建写模式,文件不存在则创建,存在则返回FileExistsError 'a' 追加写模式,文件不存在则创建,存在则在文件最后追加内容 'b' 二进制文件模
链接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4110 题意:给你两个字符串s和t,问你有多少种方法,在仅翻转一次s的子串后使得两个串相同。 题解:分两种情况。 1.两个串不同 我们先找到两个串不同点的边界值l,r
链接:https://ac.nowcoder.com/acm/contest/893/E 来源:牛客网 在ACM队暑假集训的某一天,实验室里有n个人。因为天气很热,大家都很想吃西瓜。 于是Eric买了 m个西瓜拿到了实验室。 Eric把这 n个人分别编号为1,2,3…n,他希望这n个人循环轮流来吃
/**/ #include <cstdio> #include <cstring> #include <cmath> #include <cctype> #include <iostream> #include <algorithm&
题干: There are a group of students. Some of them may know each other, while others don't. For example, A and B know each other, B and C know each othe
链接:https://ac.nowcoder.com/acm/contest/893/H 来源:牛客网 在Casya生活的世界里,一天由m个小时组成。 最近Casya的女神终于答应在接下来的n天中与Casya聊天,Casya非常激动。 在这n天中的每一天的每一个小时中女神可能会在线或者不在线, 某个
题干: Consider a group of N students and P courses. Each student visits zero, one or more than one courses. Your task is to determine whether it is pos
反素数ant 时间限制: 1 Sec 内存限制: 128 MB 题目描述 对于任何正整数x,其约数的个数记作g(x)。例如g(1)=1、g(6)=4。如果某个正整数x满足:g(x)>g(i) 0<i<x,则称x为反质数。例如,整数1,2,4,6等都是反质数。现在给定一个数N
题目大意: 有n个出车安排,一辆车能接到这个安排的条件是:1、这辆车第一次发车;2、这辆车接了上一个安排,回到这个安排的起点的时间正好是这个安排的前一分钟或者更早 解题报告: 建图然后跑最小路径覆盖。就是答案。注意搭边的条件不是光看距离,还要加上每个任务的起点到终点的时间。 AC代码:
问题 C: 【高精度】简单高精度减法 时间限制: 1 Sec 内存限制: 64 MB 题目描述 邪狼掌握了简单高精度加法程序的编写后,修罗王要求邪狼写一个简单高精度减法的程序。即求出A-B的值,其中A和B均为非负整数,其位数不超过5000。 输入 共两行数据,第一行为一个非负整数A
题干: The SUM problem can be formulated as follows: given four lists A, B, C, D of integer values, compute how many quadruplet (a, b, c, d ) ∈ A x B x
http://poj.org/problem?id=3311 The Pizazz Pizzeria prides itself in delivering pizzas to its customers as fast as possible. Unfortunately, due to cut
题干: n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and
https://www.luogu.org/problemnew/show/P2051 这次小可可想解决的难题和中国象棋有关,在一个N行M列的棋盘上,让你放若干个炮(可以是0个),使得没有一个炮可以攻击到另一个炮,请问有多少种放置方法。大家肯定很清楚,在中国象棋中炮的行走方式是:一个炮攻击到另一个
题干: 一位老木匠需要将一根长的木棒切成N段。每段的长度分别为L1,L2,......,LN(1 <= L1,L2,…,LN <= 1000,且均为整数)个长度单位。我们认为切割时仅在整数点处切且没有木材损失。 木匠发现,每一次切割花费的体力与该木棒的长度成正比,不妨设切割长度为1的
https://www.luogu.org/problemnew/show/P2704 司令部的将军们打算在N*M的网格地图上部署他们的炮兵部队。一个N*M的地图由N行M列组成,地图的每一格可能是山地(用“H” 表示),也可能是平原(用“P”表示),如下图。在每一格平原地形上最多可以布置一支炮兵部
<svg style="display: none;" xmlns="http://www.w3.org/2000/sv
题干: 一个长度为N的数组A,从A中选出若干个数,使得这些数的和是N的倍数。 例如:N = 8,数组A包括:2 5 6 3 18 7 11 19,可以选2 6,因为2 + 6 = 8,是8的倍数。 Input 第1行:1个数N,N为数组的长度,同时也是要求的倍数。(2 <= N <
https://www.luogu.org/problemnew/show/P1896 在N×N的棋盘里面放K个国王,使他们互不攻击,共有多少种摆放方案。国王能攻击到它上下左右,以及左上左下右上右下八个方向上附近的各一个格子,共8个格子。 输入格式: 只有一行,包含两个数N,K ( 1
题干: Recently, Mike was very busy with studying for exams and contests. Now he is going to chill a bit by doing some sight seeing in the city. City c
https://www.luogu.org/problemnew/show/P1879 农场主John新买了一块长方形的新牧场,这块牧场被划分成M行N列(1 ≤ M ≤ 12; 1 ≤ N ≤ 12),每一格都是一块正方形的土地。John打算在牧场上的某几格里种上美味的草,供他的奶牛们享用。 遗
1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 C ( n ,
CCF201809 -- 第一题 :买菜 问题描述 在一条街上有n个卖菜的商店,按1至n的顺序排成一排,这些商店都卖一种蔬菜。 第一天,每个商店都自己定了一个正整数的价格。店主们希望自己的菜价和其他商店的一致,第二天,每一家商店都会根据他自己和相邻商店的价格调整自己的价格。具体的,每家
<svg style="display: none;" xmlns="http://www.w3.org/2000/sv
牛客网暑期ACM多校训练营(第一场) F Sum of Maximum 杜教板子: 证明https://blog.csdn.net/Lee_w_j__/article/details/81135539 #include <cstdio> #include <iostr
题干: Homer: Marge, I just figured out a way to discover some of the talents we weren’t aware we had. Marge: Yeah, what is it? Homer: Take me for exa
题干: Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "a
枚举在那个咖啡店喝咖啡 想要计算咖啡店两侧同色的客栈的对数 枚举i求和(左边第i种颜色的个数*右边第i种颜色的个数) 前缀和+后缀和 f [
题干: After a team finished their training session on Euro football championship, Valeric was commissioned to gather the balls and sort them into baske
文章目录 L3-017 森森快递 (30 分) L3-017 森森快递 (30 分) https://www.cnblogs.com/8023spz/p/10448361.html #include<bits/stdc++.h> #define lson (o&l
题干: Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching a
<svg style="display: none;" xmlns="http://www.w3.org/2000/sv
写在前面: 代码中有的是i,j,有的是j,k,总之不唯一啊@!!!这个一定要弄清楚!!!我没有统一。。 从0开始的字符串,加速版。 void getnext() { next[0]=-1; int k=-1,j=0; while(j<len2-1) { if(
问题 C: Candles 时间限制: 1 Sec 内存限制: 128 MB 题目描述 There are N candles placed on a number line. The i-th candle from the left is placed on coordinate xi.
#include<bits/stdc++.h> using namespace std; int main(void){ int N;char c; cin>>N>>c; if(N == 0) return 0*printf("0"
<svg style="display: none;" xmlns="http://www.w3.org/2000/sv
/**/ #include <cstdio> #include <cstring> #include <cmath> #include <cctype> #include <iostream> #include <algorithm&
依赖 DEV C++ 5.11 最新版 下载安装DEV C++后,使用DEV C++打开一个随便的cpp文件,你看到的应该是这样的界面。(为了节约读者的流量,图片进行了有损压缩,但是字看得清楚) 重点是确认工具栏有AStyle选项。 相信编译运行什么的同学们肯定都会了,我就不说了。 主题
/**/ #include <cstdio> #include <cstring> #include <cmath> #include <cctype> #include <iostream> #include <algorithm&
题干: You are going to the beach with the idea to build the greatest sand castle ever in your head! The beach is not as three-dimensional as you could
文章目录 A 上课点名 B 消灭复读机 C 拾取金币 D 同学聚会 E 木工的烦恼 F 数字游戏 G 子序列问题 H 下大雪了 I 丢失的数字 J 最大岛屿 K 山区修路 学如逆水行舟,不进则退。 A 上课点名 用两个堆将数列分成两部分,
/**/ #include <cstdio> #include <cstring> #include <cmath> #include <cctype> #include <iostream> #include <algo
<svg style="display: none;" xmlns="http://www.w3.org/2000/sv
题干: As Valeric and Valerko were watching one of the last Euro Championship games in a sports bar, they broke a mug. Of course, the guys paid for it b
/**/ #include <cstdio> #include <cstring> #include <cmath> #include <cctype> #include <iostream> #include <algorithm&
题干: 粘贴不过来。。。 题目大意: 500*500带权格子,每行每列要确定一个值,使row[i]+col[j] >= val[i][j],要使所有row值和col值的和最小 输出每行的row[i],和每列的col[i]。 解题报告: 跑一边KM,自带着就把我
https://www.luogu.org/problemnew/show/P2458 五一来临,某地下超市为了便于疏通和指挥密集的人员和车辆,以免造成超市内的混乱和拥挤,准备临时从外单位调用部分保安来维持交通秩序。 已知整个地下超市的所有通道呈一棵树的形状;某些通道之间可以互相望见。总经理要求
/**/ #include <cstdio> #include <cstring> #include <cmath> #include <cctype> #include <iostream> #include <algorithm&
https://www.luogu.org/problemnew/show/P1273 某收费有线电视网计划转播一场重要的足球比赛。他们的转播网和用户终端构成一棵树状结构,这棵树的根结点位于足球比赛的现场,树叶为各个用户终端,其他中转站为该树的内部节点。 从转播站到转播站以及从转播站到所有用户终
题干: It is the middle of 2018 and Maria Stepanovna, who lives outside Krasnokamensk (a town in Zabaikalsky region), wants to rent three displays to hi
题目描述 Farmer John 想让她的奶牛准备郡级跳跃比赛,贝茜和她的伙伴们正在练习跨栏。她们很累,所以她们想消耗最少的能量来跨栏。 显然,对于一头奶牛跳过几个矮栏是很容易的,但是高栏却很难。于是,奶牛们总是关心路径上最高的栏的高度。 奶牛的训练场中有 N (1 ≤ N ≤ 300) 个站台,
https://www.luogu.org/problemnew/show/P1272 一场可怕的地震后,人们用N个牲口棚(1≤N≤150,编号1..N)重建了农夫John的牧场。由于人们没有时间建设多余的道路,所以现在从一个牲口棚到另一个牲口棚的道路是惟一的。因此,牧场运输系统可以被构建成一棵树
A. 题目大意: x坐标上1~L有L个点都是整数,每v个长度就有一个灯亮着,但是有 [ l , r ] 这段区间上有列火车挡住了,问你能看到多少亮灯。 解题报告: 大水题啊,找几个样例就会发现需要特殊处理一下左边界恰好有灯的情况。 AC代码: #include<bit
<svg style="display: none;" xmlns="http://www.w3.org/2000/sv
https://www.luogu.org/problemnew/show/P1122 小明对数学饱有兴趣,并且是个勤奋好学的学生,总是在课后留在教室向老师请教一些问题。一天他早晨骑车去上课,路上见到一个老伯正在修剪花花草草,顿时想到了一个有关修剪花卉的问题。于是当日课后,小明就向老师提出了这个问
题干: 传说在遥远的地方有一个非常富裕的村落,有一天,村长决定进行制度改革:重新分配房子。 这可是一件大事,关系到人民的住房问题啊。村里共有n间房间,刚好有n家老百姓,考虑到每家都要有房住(如果有老百姓没房子住的话,容易引起不安定因素),每家必须分配到一间房子且只能得到一间房子。 另一方面,村
链接:https://ac.nowcoder.com/acm/contest/940/J 来源:牛客网 题目描述 andy又开始种树了,他觉得老用魔法不太好,这次他决定老老实实地每天种一棵树,第i天种一颗高度为hi的树,按理说老老实实种树就完事了,哪有那么多问题呢?但是他们学校有个叫kotori的
扫一扫,把题目装进口袋
扫描二维码,进入QQ群
扫描二维码,关注牛客网公众号