HDU 3161 Iterated Difference 暴力】的更多相关文章

Iterated Difference Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 786    Accepted Submission(s): 505 Problem Description You are given a list of N non-negative integers a(1), a(2), ... , a(N).…
Little Ruins is playing a number game, first he chooses two positive integers yy and KK and calculates f(y,K)f(y,K), here f(y,K)=∑z in every digits of yzK(f(233,2)=22+32+32=22)f(y,K)=∑z in every digits of yzK(f(233,2)=22+32+32=22) then he gets the re…
2019 杭电多校 5 1005 题目链接:HDU 6628 比赛链接:2019 Multi-University Training Contest 5 Problem Description A sequence of length \(n\) is called a permutation if and only if it's composed of the first \(n\) positive integers and each number appears exactly once…
Largest Point Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5461 Description Given the sequence A with n integers t1,t2,⋯,tn. Given the integral coefficients a and b. The fact that select two elements ti and tj…
Teacher Bo 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5762 Description Teacher BoBo is a geography teacher in the school.One day in his class,he marked N points in the map,the i-th point is at (Xi,Yi).He wonders,whether there is a tetrad (A,B,C,…
Smallest Difference Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10387   Accepted: 2836 Description Given a number of distinct decimal digits, you can form one integer by choosing a non-empty subset of these digits and writing them in…
定义一种数位simth数,该数的各位之和等于其所有质因子所有位数字之和,现给出n求大于n的最小该种数,n最大不超过8位,那么直接暴力就可以了. /** @Date : 2017-09-08 14:12:08 * @FileName: HDU 1333 素因子 暴力.cpp * @Platform: Windows * @Author : Lweleth (SoungEarlf@gmail.com) * @Link : https://github.com/ * @Version : $Id$ *…
Palindrome Sub-Array 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=4618 Description A palindrome sequence is a sequence which is as same as its reversed order. For example, 1 2 3 2 1 is a palindrome sequence, but 1 2 3 2 2 is not. Given a 2-D array…
题目: http://acm.hdu.edu.cn/showproblem.php?pid=2089 题解: 暴力水过 #include<cstdio> #include<algorithm> using namespace std; ; int n,m; int f[N]; bool check(int x) { while(x) { ==||x%==) ; x/=; } ; } void init() { ;i<=1e6;i++) f[i]=f[i-]+check(i);…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6115 题意:中文题面 分析:直接维护LCA,然后暴力枚举集合维护答案即可. #include <bits/stdc++.h> using namespace std; const int maxn = 200010; const int inf = 0x3f3f3f3f; struct edge{ int to,len,next; }E[maxn*2]; vector<int>G[ma…
Shortest Path 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5636 Description There is a path graph G=(V,E) with n vertices. Vertices are numbered from 1 to n and there is an edge with unit length between i and i+1 (1≤i<n). To make the graph more in…
City Planning Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 503    Accepted Submission(s): 213 Problem Description After many years, the buildings in HDU has become very old. It need to rebui…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2615 题解:挺简单的暴力枚举,小小的分治主要是看没人写题解就稍微写一下 #include <iostream> #include <cstring> #include <cstdio> #include <algorithm> using namespace std; typedef long long ll; ll a[] , ans , sum[]; str…
题意: 维护一个有序数列{An},有三种操作: 1.添加一个元素. 2.删除一个元素. 3.求数列中下标%5 = 3的值的和. 解题思路: 看的各种题解,今天终于弄懂了. 由于线段树中不支持添加.删除操作,所以题解写的是用离线做法. 我们来看它是如何解决添加.删除的问题的. 首先将所有出现过的数记录下来,然后排序去重,最后根据去重结果建树,然后每个操作数都会对应线段树中的一个点. 遇到添加.删除操作的时候,只要把那个节点的值改变,然后将它对下标的影响处理好就可以. 那么如何处理这些操作对下标的影…
Trouble Time Limit: 5000MS   Memory Limit: 32768KB   64bit IO Format: %I64d & %I64u Submit Status Description Hassan is in trouble. His mathematics teacher has given him a very difficult problem called 5-sum. Please help him. The 5-sum problem is def…
Difference Between Primes Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3339    Accepted Submission(s): 953 Problem Description All you know Goldbach conjecture.That is to say, Every even int…
分析:暴力找循环节就好了 #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <string> #include <stack> #include <vector> #include <map> #include <queue> #inc…
pid=4775" target="_blank" style="">题目链接:hdu 4775 Infinite Go 题目大意:两个人下围棋,总共走了n步.黑棋和白棋交替走,假设一片棋的上下左右被封死,那么该片棋子就会被吃掉,问说最后黑白棋各剩多少个. 解题思路:比較恶心的模拟题,相邻同样色的棋子要用并查集连接.而且要记录每片棋子还剩的空格数.假设空格数为0的话说明该片棋子被其它颜色围住,则要剔除掉,不且将相邻的位置不同色的棋空格数加1.主要是细…
题意:给定 n,m,让你把 1 ~ n 分成 m 部分,而且每部分和是一样大的. 析:首先先判断不能分成的,第一种是 sum (1 ~ n 的和)不能被 m 整除,或者 sum / m < n,其他的情况都有解. 这个题采用的是构造加暴力搜索的思想,首先,先成对的构造解,也就 2 * m 个,每 2 * m 组,分别放到 m 个部分,这样都每部分的贡献都是一样的(最大的和最小一组,次大和次小等等),然后剩下的部分进行搜索暴力,但是要注意的是,如果剩下的不够 m 个的话,这样是不可能搜索出解的,要…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5510 思路: 一开始直接用KMP莽了发,超时了,后面发现如果前面的字符串被后面的字符串包含,那么我们就不需要用前面的字符串去比较了,把他标记掉就好了. 实现代码: #include<iostream> #include<algorithm> #include<cstring> #include<cstdio> using namespace std; ][];…
题意是每组给定一个字符串,在有限查询次数内输出所要查询区间的字典序最小的子串个数. 字典序最小的子串,就是所查询区间中字典序最小的单个字符,问题就转化成了求一段区间内字典序最小的字符个数. 开始时盲目暴力,直接用桶排序的做法一段一段去求,果然t了(这种就不贴代码了)...... 然后想到先扫一遍,求出从字符串首位到第 i 位的最小字符数,再用一个数组存第 0 位到第 i 位的最小字符,比较第 i 位的字符和前 i - 1 位的最小字符,第 i 位更小的话就更新最小字符和最小字符数......这样…
题目传送:http://acm.hdu.edu.cn/showproblem.php?pid=6152 Problem Description It is well known that small groups are not conducive of the development of a team. Therefore, there shouldn’t be any small groups in a good team.In a team with n members,if there…
Abelian Period 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5908 Description Let S be a number string, and occ(S,x) means the times that number x occurs in S. i.e. S=(1,2,2,1,3),occ(S,1)=2,occ(S,2)=2,occ(S,3)=1. String u,w are matched if for each…
Born Slippy 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5735 Description Professor Zhang has a rooted tree, whose vertices are conveniently labeled by 1,2,...,n. And the i-th vertex is assigned with weight wi. For each s∈{1,2,...,n}, Professor Zh…
Problem E. TeaTree Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 722    Accepted Submission(s): 255 Problem Description Recently, TeaTree acquire new knoledge gcd (Greatest Common Divisor),…
题意:不说了很好懂. 这题这么水= =...当时竟然没有勇气暴力搜一下.昨天(好吧前天.)比赛的时候胃疼,看到这题想了一个办法就是对每一个出现最短的C串前后连接然后对这个串求最长公共子序列.其实优化一下就是现在的答案啊~~!!!!给赵鹏说了赵鹏说不可能这么过..然后就没想.就这样这么水的一道题都没过!!!!桑心啊~ 代码: #include <iostream> #include <string.h> #include <stdio.h> #include <ve…
题意:给定一个8*8的棋盘,然后要懂黑白棋,现在是黑棋走了,问你放一个黑子,最多能翻白子多少个. 析:我是这么想的,反正才是8*8的棋盘,那么就暴吧,反正不会超时,把每一个格能暴力的都暴力,无非是上,下,左,右,左上,左下,右上,右下, 然后都试试就好了.不过懂点黑白棋的还是好做一点. 代码如下: #include <iostream> #include <cstdio> #include <cstring> #include <queue> #includ…
abs Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Problem Description Given a number x, ask positive integer y≥2, that satisfy the following conditions:1. The absolute value of y - x is minimal2. To prime facto…
hdu 5386 Cover Description You have an matrix.Every grid has a color.Now there are two types of operating: L x y: for(int i=1;i<=n;i++)color[i][x]=y; H x y:for(int i=1;i<=n;i++)color[x][i]=y; Now give you the initial matrix and the goal matrix.There…
Factory Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 132768/132768 K (Java/Others)Total Submission(s): 367    Accepted Submission(s): 124 Problem Description 我们将A省简化为由N个城市组成,某些城市之间存在双向道路,而且A省的交通有一个特点就是任意两个城市之间都能通过道路相互到达,且在不重复经过城市的情况下任意两个…