BNU - 49102】的更多相关文章

进化之地(Evoland) Time Limit: 1000ms Case Time Limit: 1000ms Memory Limit: 65536KB 64-bit integer IO format: %lld      Java class name: Main Submit Status PID: 49102 Font Size:   最近xhyu和hwq欢乐地通了一款RPG(Role-playing game)神作——<进化之地>,这是一部用RPG讲述RPG发展史的RPG.随 着…
题目链接:http://acm.bnu.edu.cn/bnuoj/problem_show.php?pid=2418 解题报告:就是给你n个数,然后让你求这个数列的逆序对是多少?题目中n的范围是n < 500000,所以,暴力是不行的.还是第一次学会用线段树求逆序数,这种方法的时间复杂度是n * log n,是不是很快呢,利用了线段树查询速度快的优势.具体的方法如下: 这里先说一下,如果输入的n个数不是连续的,也就是说把这n个数按从小到大的顺序排列起来不是连续的话,还要先离散化一下,其实也就是把…
留着当个模板用,在BNU上AC,在LA上RE……可能是java的提交方式不同??? 数和运算符各开一个栈. 表达式从左到右扫一遍,将数存成大数,遇到数压在 数的栈,运算符压在 运算符的栈,每当遇到右括号时,弹出 数的栈 的栈顶头两个元素,弹出 运算符的栈 顶的头一个元素,进行运算,将运算结果压回 数的栈 中.最后输出栈顶元素. 运算过程中把不符合情况的判掉. 我写的第二个java的题,竟然1A……这世界太不可思议了= = import java.util.*; import java.math.…
题目链接:bnu 34982 Beautiful Garden 题目大意:给定一个长度为n的序列,问说最少移动多少点,使得序列成等差序列,点的位置能够为小数. 解题思路:算是纯暴力吧.枚举等差的起始和中间一点,由于要求定中间一点的位置.所以这一步是o(n3);然后用o(n)的算法确定说须要移动几个来保证序列等差. #include <cstdio> #include <cstring> #include <vector> #include <algorithm&g…
pid=34986" target="_blank" style="">题目连接:bnu 34986 Football on Table 题目大意:给出桌子的大小L,W,然后是球的起始位置sx,sy,以及移动的向量dx,dy.然后给出n.表示有n个杆,对于每一个杆.先给出位置x,以及杆上有多少个小人c,给出小人的宽度.再给出c个小人间的距离.如今问说球有多少个概率能够串过全部人. 解题思路.对于每一个杆求无阻挡的概率.注意概率 = 空隙 / 可移动的…
https://www.bnuoj.com/v3/problem_show.php?pid=4096 对于一个序列a,我们定义它的逆序数为满足a[i]>a[j]且i<j的有序对<i,j>的个数,这样的有序对称为逆序对. 例如 a[0]=1,a[1]=2,a[2]=4,a[3]=5,a[4]=3,存在的逆序对就有<2,4>和<3,4>,其逆序数就是2. 现在,给你一个长为N的序列,要求恰好执行K次交换操作,每次交换只能在相邻的两个数之间进行,问得到的结果序列其…
题目链接:http://acm.bnu.edu.cn/bnuoj/problem_show.php?pid=34990 DEBUG了非常久,还是legal的推断函数写错了... 此题做法.枚举String1的起始位置,对string2的长度进行二分.求出最长公共前缀,然后跳过一个不匹配的地方,然后继续二分匹配,再去掉一个不匹配的地方 //700-800MS   对于hash而言已经算比較快了 以下的是自己又一次写的: #include <cstdio> #include <cstring…
A Matrix Time Limit: 2000ms Memory Limit: 65536KB   64-bit integer IO format: %lld      Java class name: Main Prev Submit Status Statistics Discuss Next Font Size: + - Chaos King loves permutation and matrix, now he is trying to find out some relatio…
题意:给出n,输出n位超级质数,超级质数的定义为“依次去掉右边一位后仍然为质数的数” 因为一个n位质数去掉右边一位数之后仍然为质数,说明它是由n-1位超级质数演变而来的, 同理,n-1位超级质数也由n-2位超级质数演变而来- - -- - 所以按照位数从第一位广搜到n位即可 注意的地方是判重,最开始用的是一个vis[]数组,可是因为位数有8位,mle了 后来又想把每个数分成两半,比如73939133,可以这样判断vis[7393][9133]是否为1,= =后来发现这样用的内存貌似更多= = 最…
题目链接:http://www.bnuoj.com/v3/problem_show.php?pid=51276 具体题意不描述了,一眼看过去就是并查集,关键是添加边以后更新答案.我是开个二维的数组ans记录答案,vector容器存储直接或间接相连的点(包括本身). 代码如下: #include <iostream> #include <cstdio> #include <cstring> #include <vector> using namespace s…
http://www.bnuoj.com/bnuoj/problem_show.php?pid=4359 [题意]:输入N,表示几位数,0-这个N位数,有多少个满足条件的号码,不满足的情况为出现4,13的情况 [题解]: 写暴力代码找规律 1 9 2 80 3 711 4 6319 得出规律    a[i] = a[i-1]*9 - a[i-2] 另外注意处理减法出现负数的情况 [code]: #include <iostream> #include <stdio.h> #incl…
http://www.bnuoj.com/bnuoj/problem_show.php?pid=4358 [题意]:给定起始位置和方向和目的地,按照左转.前进.右转.后退的优先级递减,也就是说能左转就左转,不能则继续前进,...,能走到T的位置输出YES,不能则输出NO... [题解]: 首先我们知道YES肯定就是走到了,若出现NO的情况,肯定是出现了死循环,这题主要考标记,什么时候表示已经进入了死循环呢?每个位置有一个方向,我们将这个位置第一次出现方向的时候标记下来,注意是第一次的方向噢,第二…
http://www.bnuoj.com/bnuoj/problem_show.php?pid=4353 [题意]:每次选择一个小格后,该小格的右上部分就全被删去了,且要求每次至少删去一个格子,选中左下角格子的人算输. [题解]:这个题嘛,这个题嘛,这个题嘛,还是看代码吧,不解释... [code]: #include <iostream> #include <stdio.h> #include <string.h> #include <algorithm>…
http://www.bnuoj.com/bnuoj/problem_show.php?pid=4352 [题意]:给你个长串,输出该长串中能第一放出的技能,每个技能有对应的一个小子串,不能放出任何技能输出“Nothing Happened” [题解]:暴力匹配(数据量不大),若数据量巨大,则得用ac自动机解 [code]: #include <iostream> #include <stdio.h> #include <string.h> #include <a…
http://www.bnuoj.com/bnuoj/problem_show.php?pid=4351 [题意]:用最小的矩形框,框住像素点差超过5的点. [题解]:求坐标x,y最大最小值 [code]: #include <iostream> #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; ][]; int abs(int x) { ?-x:…
分析(引入Q神题解  %%%Q) 如果使用可持久化并查集,二分答案判定连通性,复杂度是O(mlog3n),不能在时限内出解.考虑到并查集实际上是一棵树,可以尝试在边上维护一些信息,假设t时刻加了一条边(u,v),若u和v此时未连通,则在root(u)和root(v)之间连一条权值为t的边,表示u所在集合以及v所在集合在t时刻连通,这样对于一组查询(u,v),如果u和v位于同一个连通块内,只需找出并查集中u到v的路径上的权值最大值,很显然这样是不能路径压缩的,但是可以按秩合并保证树高是O(logn…
http://www.bnuoj.com/bnuoj/problem_show.php?pid=29376 我直接暴力搜索的. 剪枝: 1.步骤最多只有4步,超过4步则退出 2.油的行程相加后的总和距离大于剩余距离时也退出 AC代码: #include<iostream> #include<cstdio> #include<algorithm> using namespace std; int yn; int a[1010]; bool cmp(int a, int b…
http://www.bnuoj.com/bnuoj/problem_show.php?pid=29364 这个题被坑了. 题意:密码就是那些数字里面的数,转换成二进制后1最少的那个数,当1的个数相同的时候,要选最小的那个数. AC代码: #include<iostream> #include<cstdio> #include<algorithm> using namespace std; bool cmp(int a, int b) { return a < b…
好久没写过单组数据的题目了 QAQ 赤裸裸的模板题 #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <cmath> using namespace std; #define sqr(x) ((x) * (x)) ; ; const double PI = acos(-1.0);//3.1415926535897932384…
链接: http://www.bnuoj.com/bnuoj/problem_show.php?pid=26579 http://www.bnuoj.com/bnuoj/contest_show.php?cid=2318#problem/25687 Andrew the Ant Time Limit: 4000ms Memory Limit: 65536KB   64-bit integer IO format:  %lld      Java class name:  Main Prev  S…
http://www.bnuoj.com/bnuoj/problem_show.php?pid=2490 这个题是先输入一个整数n,说明有几个数据,然后输入n个整数,然后用三个#分开,后面输入整数k,代表有k个数据,后面每个数据代表查询前面那几个整数中从小到大排序后的第几个数. AC代码: #include<iostream> #include<cstdio> #include<algorithm> using namespace std; bool cmp(int a…
http://www.bnuoj.com/bnuoj/problem_show.php?pid=1596 这个题一开始以为要求最少移动次数,把我吓到了,原来只要求最少移动几个方块就行了..这一下就变简单很多了.. AC代码: #include<iostream> #include<cstdio> #include<algorithm> using namespace std; bool cmp(int a, int b) { return a<b; } int m…
题意:给一个二维地图,每个点为障碍或者空地,有一个机器人有三种操作:1.向前走:2.左转90度:3.右转90度.现给定起点和终点,问到达终点最短路的条数. 思路:一般的题目只是求最短路的长度,但本题还要求出相应的条数.比赛时只记录最少的步数,却没有记录以最少步数到达该点的的条数,让他们一直入队.......铁定tle....... 只要记录好到达该点最少步数的条数,减少了很多重复入队.......... #include <cstdio> #include <cstring> #i…
模拟 #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<algorithm> using namespace std; +; char t1[maxn],t2[maxn]; int g1,g2,h1,h2; int main() { int T; scanf("%d",&T); while(T--) { g1=g2=…
#include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<algorithm> using namespace std; int main() { int T; scanf("%d",&T); while(T--) { int x; ;i<=;i++) scanf("%d",&x); pri…
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; +; char s[maxn]; int main() { int T; scanf("%d",&T); while(T--) { scanf("%s",s); int len=strlen(s); ; ;s[i];i++) { <len&&i+<…
二进制++高精度取模 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; ; long long a[maxn]; long long sumA[maxn]; int aa,bb; int len; long long n; int Base[maxn]; int tot; int ans[maxn]; void init1() { memset(sumA,,sizeof…
#include<cstdio> #include<algorithm> using namespace std; +; struct Homework { long long st; long long len; }h[maxn]; int n; bool cmp(const Homework&a,const Homework&b) { return a.st<b.st; } int main() { int T; scanf("%d",…
#include <cstdio> #define _(l) int l #define ___(l,L) for (_(o)=0,x=l o*2;o<x;o++)O= L o; #define __ _ ( _ ) const __=0x80000000; _(main)() { int T; scanf("%d",&T); while(T--){ _(O); scanf("%d",&O); if(O&_)___(-,-~…
#include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; int ans; int T; int a,b; int main() { scanf("%d",&T); while(T--) { scanf("%d%d",&a,&b); ans=max(a,b)*; ) an…