ural 1219. Symbolic Sequence】的更多相关文章

1219. Symbolic Sequence Time limit: 1.0 secondMemory limit: 64 MB Your program is to output a sequence of 1 000 000 lowercase Latin letters. This sequence should satisfy the following restrictions: Every letter occurs not more than 40 000 times in th…
题目传送门 /* 记忆化搜索(DP+DFS):dp[i][j] 表示第i到第j个字符,最少要加多少个括号 dp[x][x] = 1 一定要加一个括号:dp[x][y] = 0, x > y; 当s[x] 与 s[y] 匹配,则搜索 (x+1, y-1); 否则在x~y-1枚举找到相匹配的括号,更新最小值 */ #include <cstdio> #include <algorithm> #include <cmath> #include <iostream&…
URAL 1183 思路:区间dp,打印路径,详见http://www.cnblogs.com/widsom/p/8321670.html 代码: #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<algorithm> using namespace std; #define ll long l…
题目地址:Ural 1183 最终把这题给A了.. .拖拉了好长时间,.. 自己想还是想不出来,正好紫书上有这题. d[i][j]为输入序列从下标i到下标j最少须要加多少括号才干成为合法序列.0<=i<=j<len (len为输入序列的长度). c[i][j]为输入序列从下标i到下标j的断开位置.假设没有断开则为-1. 当i==j时.d[i][j]为1 当s[i]=='(' && s[j]==')' 或者 s[i]=='[' && s[j]==']'时,d…
题目链接 #include <cstdio> #include <string> #include <cstring> #include <iostream> using namespace std; #define LL long long #define INF 2000000000 LL p[]; int main() { int i; LL a,fa,fb,b,n; LL str,mid,end; cin>>a>>fa>…
题目链接 题意 : 给你一串由括号组成的串,让你添加最少的括号使该串匹配. 思路 : 黑书上的DP.dp[i][j] = min{dp[i+1][j-1] (sh[i] == sh[j]),dp[i][k]+dp[k+1][j](i<=k<j)}.输出的时候递归,其实我觉得输出比dp部分难多了..... #include <stdio.h> #include <string.h> #include <iostream> using namespace std…
题目链接 题意 :给你第 i 项的值fi,第 j 项的值是 fj 让你求第n项的值,这个数列满足斐波那契的性质,每一项的值是前两项的值得和. 思路 :知道了第 i 项第j项,而且还知道了每个数的范围,二分求第 i+1项,然后根据性质求下去,求到第 j 项的时候看看通过二分求出来的值与给定的第j项的值大小关系,来确定下一次二分的值,输出的时候注意方向. #include <stdio.h> #include <string.h> #include <iostream> #…
列表: URAL 1225 Flags URAL 1009 K-based Numbers URAL 1119 Metro URAL 1146 Maximum Sum URAL 1203 Scientific Conference URAL 1353 Milliard Vasya's Function URAL 1260 Nudnik Photographer URAL 1012 K-based Numbers. Version 2 URAL 1073 Square Country URAL 1…
题目传送门 题意:问第k个长度为n的01串是什么(不能有相邻的1) 分析:dp[i][0/1] 表示前i个,当前第i个放1或0的方案数,先预处理计算,dp[i][1]只能有dp[i-1][0]转移过来.k -= dp[n][0] 表示当前放0的方案数不够了,所以必须放1,那么dp[n][0]个方案数都不能用了,相当于k减去这么多.详细解释 代码: #include <cstdio> #include <algorithm> #include <cmath> #inclu…
1247. Check a Sequence Time limit: 0.5 secondMemory limit: 64 MB There is a sequence of integer numbers A1, A2, …, AS, and a positive integer N. It's known that all elements of the sequence {Ai} satisfy the restriction 0 ≤ Ai ≤ 100. Moreover, it's kn…
目录 Ural 1248 Sequence Sum 题解 题意 题解 程序 Ural 1248 Sequence Sum 题解 题意 给定\(n\)个用科学计数法表示的实数\((10^{-100}\sim10^{100})\),输出它们的和. Tip: 一个实数可以用科学计数法表示为\(x\times10^y\),其中\(1\le x<10\) \(x\)为实数,\(y\)是整数.输入时表示为\(xey\).保证输入的实数有\(19\)位有效数字.输出时用科学计数法,必须包括\(19\)位正确数…
1306. Sequence Median Time limit: 1.0 secondMemory limit: 1 MBLanguage limit: C, C++, Pascal Given a sequence of N nonnegative integers. Let's define the median of such sequence. If N is odd the median is the element with stands in the middle of the…
题意:求一串数字里的中位数.内存为1M.每个数范围是0到2的31次方-1. 思路:很容易想到把数字全部读入,然后排序,但是会超内存.用计数排序但是数又太大.由于我们只需要第n/2.n/2+1大(n为偶数)或第(n+1)/2大(n为奇数).所以可以用优先队列来维护最值,这样只需要存一半元素(n/2+1个元素)就可以了. #include<cstdio> #include<algorithm> #include<queue> #define UL unsigned int…
[题意]给出n(1~250000)个数(int以内),求中位数 [题解]一开始直接sort,发现MLE,才发现内存限制1024k,那么就不能开int[250000]的数组了(4*250000=1,000,000大约就是1M内存). 后来发现可以使用长度为n/2+1的优先队列,即包含前一半的数以及中位数,其他数在读入的时候就剔除,这样可以省一半的空间. #include<bits/stdc++.h> #define eps 1e-9 #define FOR(i,j,k) for(int i=j;…
第13个位置第5个Bit :13>num[4] =>1 第四个bit 13-num[4]=5 :5<num[3] =>0 ,3-1 第三个Bit 5>num[2](3) 5-num[2]=2 ... #include<stdio.h> ]; void init() { num[]=; num[]=; ; ) { num[k]=num[k-]+num[k-]; k++; } } int main(void) { init(); int n,k; while(scan…
题目链接:https://cn.vjudge.net/contest/275079#problem/D 具体思路:首先,我们可以观察到1-n位数的种数连起来是一个很有规律的数列,然后我们开始倒序建立. 具体思路见代码: #include<iostream> #include<cstring> #include<iomanip> #include<stdio.h> #include<cmath> using namespace std; # def…
1339. Babies Time limit: 1.0 secondMemory limit: 64 MB O tempora! O mores! Present-day babies progress quickly. There are exactly k boys and k girls in the kindergarten. Some boys like some girls. But in this age the boys are still knights, so, if so…
1242. Werewolf Time limit: 1.0 secondMemory limit: 64 MB   Knife. Moonlit night. Rotten stump with a short black-handled knife in it. Those who know will understand. Disaster in the village. Werewolf. There are no so many residents in the village. Ma…
1155. Troubleduons Time limit: 0.5 secondMemory limit: 64 MB Archangel of the Science is reporting:“O, Lord! Those physicists on the Earth have discovered a new elementary particle!”“No problem, we’ll add another parameter to the General Equation of…
这几天扫了一下URAL上面简单的DP 第一题 简单递推 1225. Flags #include <iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; #define LL long long LL dp[][]; int main() { int i,n; scanf("%d",&n); dp[][] = ;d…
Consider the sequence of numbers ai, i = 0, 1, 2, …, which satisfies the following requirements: a0 = 0 a1 = 1 a2i = ai a2i+1 = ai + ai+1 for every i = 1, 2, 3, … . Write a program which for a given value of n finds the largest number among the numbe…
Ural doctors worry about the health of their youth very much. Special investigations showed that a lot of clever students instead of playing football, skating or bicycling had participated in something like Programming Olympiads. Moreover, they call…
Improvise a Jazz Solo with an LSTM Network Welcome to your final programming assignment of this week! In this notebook, you will implement a model that uses an LSTM to generate music. You will even be able to listen to your own music at the end of th…
POJ 上的一套水题,哈哈~~~,最后一题很恶心,不想写了~~~ Rope Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7410   Accepted: 2603 Description Plotters have barberically hammered N nails into an innocent plane shape, so that one can see now only heads. Moreove…
Z - Bus Routes Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice URAL 1137 Description Several bus routes were in the city of Fishburg. None of the routes shared the same section of road, though commo…
Summary Learn about the initial, low-level startup sequence and the hardware platform functions that are performed when the boot loader and OEM abstraction layer (OAL) are developed and the kernel is run. The startup sequence is an integral part of d…
Boxes Time Limit: 600ms Memory Limit: 16384KB This problem will be judged on Ural. Original ID: 111464-bit integer IO format: %lld      Java class name: (Any)   N boxes are lined up in a sequence (1 ≤ N ≤ 20). You have A red balls and B blue balls (0…
2031. Overturned Numbers Time limit: 1.0 second Memory limit: 64 MB Little Pierre was surfing the Internet and came across an interesting puzzle: What is the number under the car? It took some time before Pierre solved the puzzle, but eventually he u…
Sightseeing Trip Time Limit: 2000ms Memory Limit: 16384KB This problem will be judged on Ural. Original ID: 100464-bit integer IO format: %lld      Java class name: (Any)   There is a travel agency in Adelton town on Zanzibar island. It has decided t…
oracle创建序列化: CREATE SEQUENCE seq_itv_collection            INCREMENT BY 1  -- 每次加几个              START WITH 1399       -- 从1开始计数              NOMAXVALUE        -- 不设置最大值              NOCYCLE               -- 一直累加,不循环              CACHE 10; oracle修改序列…