FZU 1627 Revival's road】的更多相关文章

矩阵快速幂. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #include<map> #include<set> #include<queue> #i…
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1627 http://acm.fzu.edu.cn/problem.php?pid=2238 对应的51NOD这个题,先把n--和没m-- 再套公式 #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <algorit…
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's…
Ikki's Story I - Road Reconstruction Time Limit: 2000MS   Memory Limit: 131072K Total Submissions: 7659   Accepted: 2215 Description Ikki is the king of a small country – Phoenix, Phoenix is so small that there is only one city that is responsible fo…
题目连接:http://acm.fzu.edu.cn/problem.php?pid=2137 题解: 枚举x位置,向左右延伸计算答案 如何计算答案:对字符串建立SA,那么对于想双延伸的长度L,假如有lcp(i-L,i+1)>=L那么就可以更新答案 复杂度  建立SA,LCP等nlogn,枚举X及向两边延伸26*n #include<iostream> #include<algorithm> #include<cstdio> #include<cstring…
题目链接:http://acm.fzu.edu.cn/problem.php?pid=1914 题意: 给出一个数列,如果它的前i(1<=i<=n)项和都是正的,那么这个数列是正的,问这个数列的这n种变换里, A(0): a1,a2,-,an-1,an A(1): a2,a3,-,an,a1 - A(n-2): an-1,an,-,an-3,an-2 A(n-1): an,a1,-,an-2,an-1 问有多少个变换里,所以前缀和都是正整数. 思路:因为变换是a[n]后面接着a[1]所以我们把…
 FZU 2105  Digits Count Time Limit:10000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Practice Description Given N integers A={A[0],A[1],...,A[N-1]}. Here we have some operations: Operation 1: AND opn L R Here opn, L and R are intege…
原题:http://acm.fzu.edu.cn/problem.php?pid=2112 首先是,票上没有提到的点是不需要去的. 然后我们先考虑这个图有几个连通分量,我们可以用一个并查集来维护,假设有n个连通分量,我们就需要n-1条边把他们连起来. 最后对于每个联通分量来说,我们要使它能一次走完,就是要求他是否满足欧拉通路,也就是这个联通分量中至多有2个度为奇数的点,每多出2个度为奇数的点,就多需要一条边(因为单个连通分量的所有点的度数之和为偶数,所以不可能存在奇数个奇数度数的点). #inc…
FZU 2107 Hua Rong Dao Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u  Practice  Description Cao Cao was hunted down by thousands of enemy soldiers when he escaped from Hua Rong Dao. Assuming Hua Rong Dao is a narrow aisl…
 FZU 2112 Tickets Time Limit:3000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Practice Description You have won a collection of tickets on luxury cruisers. Each ticket can be used only once, but can be used in either direction betwee…
 FZU 2102   Solve equation Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u  Practice Description You are given two positive integers A and B in Base C. For the equation: A=k*B+d We know there always existing many non-nega…
 FZU 2110  Star Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u  Practice Description Overpower often go to the playground with classmates. They play and chat on the playground. One day, there are a lot of stars in the sk…
Fire Game Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice FZU 2150 Description Fat brother and Maze are playing a kind of special (hentai) game on an N*M board (N rows, M columns). At the beginning,…
http://acm.timus.ru/problem.aspx?space=1&num=1627 给一个无向图,问可以有多少生成树 参照     周冬<生成树的计数及其应用> 代码: import java.io.File; import java.io.FileNotFoundException; import java.math.BigDecimal; import java.math.BigInteger; import java.util.Scanner; class Fra…
Description   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 testcases. Each testcase, there is one line contains three integers A, B and C, separated by a sin…
Problem 1686 神龙的难题 Accept: 397    Submit: 1258Time Limit: 1000 mSec    Memory Limit : 32768 KB  Problem Description 这是个剑与魔法的世界.英雄和魔物同在,动荡和安定并存.但总的来说,库尔特王国是个安宁的国家,人民安居乐业,魔物也比较少.但是.总有一些魔物不时会进入城市附近,干扰人民的生活.就要有一些人出来守护居民们不被魔物侵害.魔法使艾米莉就是这样的一个人.她骑着她的坐骑,神龙米格…
C. Road to Cinema time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t m…
Road Trip Time Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:65536KB Total submit users: 29, Accepted users: 29 Problem 12882 : No special judgement Problem description You are planning a road trip to visit your friends, each of whom live in…
题目链接: 传送门 find the most comfortable road Time Limit: 1000MS     Memory Limit: 32768 K Description XX星有许多城市,城市之间通过一种奇怪的高速公路SARS(Super Air Roam Structure---超级空中漫游结构)进行交流,每条SARS都对行驶在上面的Flycar限制了固定的Speed,同时XX星人对 Flycar的"舒适度"有特殊要求,即乘坐过程中最高速度与最低速度的差越小…
告诉你若干个(<=100)武器的花费以及武器能消灭的怪物编号,问消灭所有怪物(<=100)的最小花费...当然每个武器可以无限次使用,不然这题就太水了╮(╯▽╰)╭ 这题当时比赛的时候连题都还没看就结束了....赛后一看,果断是重复覆盖... 不过之后一直没敲...然后今天算是补回来吧,同时也把好久以前学的DLX复习一下... DLX的话,双向十字链表...具体的话,百度Google什么的dancing links... 一开始敲的时候还是挺顺利的,因为之前做过几次重复覆盖都是直接拿精确覆盖的…
 FZU 2148  Moon Game Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u   Description Fat brother and Maze are playing a kind of special (hentai) game in the clearly blue sky which we can just consider as a kind of two-dimen…
FZU 2150 Fire Game Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u   Description Fat brother and Maze are playing a kind of special (hentai) game on an N*M board (N rows, M columns). At the beginning, each grid of this bo…
http://acm.fzu.edu.cn/problem.php?pid=1977 题意:n×m的网格,有3种格子,'O'必须经过.'*'可以选择经过.'X'不能经过.现在要求路径经过所有'O'且是简单回路的数量 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; typedef long long ll; struct H { static const int…
/****************************************************************** 题目: 志愿者选拔(FZU 1894) 算法: 单调队列 算法思想: 在每个元素入队的时候入队的时候,使队列单调,查找 的时候就能很快找到最值. *******************************************************************/ #include<cstdio> #include<cstring>…
http://acm.fzu.edu.cn/problem.php?pid=2214   Problem Description Given a set of n items, each with a weight w[i] and a value v[i], determine a way to choose the items into a knapsack so that the total weight is less than or equal to a given limit B a…
http://acm.fzu.edu.cn/problem.php?pid=2225   Problem Description 在打败了易基•普罗布朗.诺姆•普罗布朗之后,小茗同学开始挑战哈德•普罗布朗. 一番交战之后,哈德展开了一大波攻击.小茗同学为了抵御攻击,一边放魔法阵一边放魔法阵,然后他也不知道自己一共放了几个魔法阵.回收魔法阵是需要花费时间的,为了抵御下一波攻击,小茗同学需要知道自己共放了几个魔法阵,由于情况紧急,这个任务需要由你来完成. 魔法阵是三角形△的,比如 .........…
http://acm.fzu.edu.cn/problem.php?pid=2233 Problem Description 为了帮助柯南回到一米七四,阿笠博士夜以继日地研究APTX4869的解药.他得出了如下结果: 1.解药由n种原料构成: 2.对于两种不同的的原料a,b,它们之间有个影响值f(a,b): 3.需要把原料分成两个部分X,Y,每部分中至少有一种原料: 4.解药的效果由分别属于X,Y的原料之间,最小的影响值决定,即 效果=min{f(a,b)|a∈X,b∈Y)} 博士需要你帮忙求出…
Design road Problem's Link:   http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1548 Mean: 目的:从(0,0)到达(x,y).但是在0~x之间有n条平行于y轴的河,每条河位于xi处,无限长,wi宽,并分别给出了建立路和桥每公里的单价 求:到达目标的最小费用. analyse: 比赛的时候一直没想到思路,第二个样列怎么算都算不对,赛后才知道是三分. 首先把所有的桥移到最右端,然后三分枚举路和河的交点. Time…
传送门:hdu 5861 Road 题意: 水平线上n个村子间有 n-1 条路. 每条路开放一天的价格为 Wi 有 m 天的操作,每天需要用到村子 Ai~Bi 间的道路 每条路只能开放或关闭一次. (不能重复开关) 求每天的最小花费. 思路: 第一次线段树:维护每条路第一次和最后一次被用到的天数.以下代码维护了 mn:第一次被用到,mx:最后一次被用到,lazy:被更新的最大值若当前区间被lazy维护而没有更新到点,那么这个子节点的最小值就可能被改变.所以我这里的子节点更新是根据父节点的最大和最…
C - Prime number or not Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice FZU 1649 Description Your task is simple.Give you a number N, you should judge whether N is a prime number or not. Input There…