摘要:
题目描述 对于一个给定的序列a1, …, an,我们对它进行一个操作reduce(i),该操作将数列中的元素ai和ai+1用一个元素max(ai,ai+1)替代,这样得到一个比原来序列短的新序列。这一操作的代价是max(ai,ai+1)。进行n-1次该操作后,可以得到一个长度为1的序列。 我们的任务 阅读全文
摘要:
题意翻译 给你一串数列a.对于一个质数p,定义函数f(p)=a数列中能被p整除的数的个数.给出m组询问l,r,询问[l,r]区间内所有素数p的f(p)之和. 题目描述 Recently, the bear started studying data structures and faced the 阅读全文
摘要:
The BFS algorithm is defined as follows. to n. Initialize q as a new queue containing only vertex 1, mark the vertex 1 as used. Extract a vertex v fro 阅读全文
摘要:
题意: 大概意思是有 n 个点,现在有 q 个方案 ,第 i 个方案耗费为 ci ,使 Ni 个点联通 ,当然也可以直接使两点联通 ,现求最小生成树的代价。 两点直接联通的代价是欧几里得距离的平方; 由于0<=q<=8,所以我们考虑二进制枚举; 该位为1表示选择该方案,然后每次求一遍cost ,最后 阅读全文
摘要:
https://www.luogu.org/problemnew/show/P4942 上面为原题地址; 引理: 一个数字除以9的余数等于它的各位数字之和除以9的余数 那么我们将其各个数字加起来%9即可; 当然用等差数列公式更快; 阅读全文
摘要:
Try guessing the statement from this picture: You are given a non-negative integer d . You have to find two non-negative real numbers a and b such tha 阅读全文
摘要:
Mahmoud was trying to solve the vertex cover problem on trees. The problem statement is: Given an undirected tree consisting of n nodes, find the mini 阅读全文
摘要:
题目描述 You are given an undirected connected weighted graph consisting of n n n vertices and m m m edges. Let's denote the length of the shortest path f 阅读全文