Time of Update: 2018-12-03
原題串連:http://acm.hdu.edu.cn/showproblem.php?pid=1010思路:dfs 深度優先搜尋+剪枝
Time of Update: 2018-12-03
#include<stdio.h>#include<memory.h>#include <iostream>#include<queue>using namespace std;const int MAX=362882;int s[9]={1,10,100,1000,10000,100000,1000000,10000000,100000000};int jie[9]={0,1,2,6,24,120,720,5040,40320};int
Time of Update: 2018-12-03
RMAN> startup nomount已串連到目標資料庫 (未啟動)Oracle 常式已啟動系統全域地區總計 135338868 位元組Fixed Size 453492 位元組Variable Size 109051904 位元組Database Buffers 25165824 位元組Redo Buffers 667648 位元組RMAN&
Time of Update: 2018-12-03
#include <iostream>#include <cstring>#include <cstdio>using namespace std; char s[20001],ans[20001]; void workk(int l,int r,int ll,int rr){ if (l>r) return; if (l==r){ans[ll-1]=s[l-1];return;} int
Time of Update: 2018-12-03
若把n個盤子從柱子a通過柱子b移到柱子c,則先把n-1個盤子從柱子a移動柱子b,再把第n個盤子從a移道c,再把n-1個盤子從b移到a。所以當判斷序列是否符合把n個盤子從a移到c時,第n個只能出現在柱子a的最底部,或柱子c的最底部,否則這個序列錯的。當第n個盤子在a的最底部時,則繼續判斷剩下的序列是否把n-1個盤子從a移到b。當第n個盤子在c的最底部時,則繼續判斷剩下的序列是否把n-1個盤子從b移到c。#include <cstdio>#define maxn 120using
Time of Update: 2018-12-03
題目地址:http://ac.jobdu.com/problem.php?pid=1528迴文大家應該都知道了,正反看都一樣,題目意思就是求一個字串的子串,要求這個子串是迴文。最簡單的辦法:暴力法:(果斷的TLE了)判斷s[i,j]是不是迴文#include<iostream>#include<string>#include<string.h>#include<cstdio>#include<ctype.h>#include<al
Time of Update: 2018-12-03
題意:有一個方陣有n行n列(3<=n<=9),共有n*n個人。現在已知他們的身高為170~200厘米之間。求一種可行的方案將他們排在方陣中,使得同一行、同一列中,高度總是從中間向兩邊遞減解法:對輸入的資料從大往小遍曆,對矩陣從中央開始進行bfs即可。貌似是桶排序。#include <iostream>#include <queue>using namespace std;const int mov[4][2]={0,1,0,-1,1,0,-1,0};int
Time of Update: 2018-12-03
1021. CouplesDescriptionN couples are standing in a circle, numbered consecutively clockwise from 1 to 2N. Husband and wife do not always stand together. We remove the couples who stand together until the circle is empty or we can't remove a couple
Time of Update: 2018-12-03
二分法作為分治中最常見的方法,適用於單調函數,逼近求解某點的值。但當函數是凸性函數時,二分法就無法適用,這時三分法就可以“大顯身手”~~ ,類似二分的定義Left和Right,mid = (Left + Right) / 2,midmid = (mid + Right) / 2; 如果mid靠近極值點,則Right = midmid;否則(即midmid靠近極值點),則Left =
Time of Update: 2018-12-03
水題一道,要注意兩點:1、題目中分配方式沒有說明清楚2、浮點數下取整的時候要注意,比如4.9999999其實應該是5#include <iostream>#include <cmath>using namespace std;int main(){ long double n,arr[107],sum=0,cnt=0,mark[107]={0},sum2=0; cin>>n; for(int i=0;i<n;i++) {
Time of Update: 2018-12-03
一般思路是由組合算排列,現在藉助Next_permutation函數由排列到組合。1.組合讀入一個字串,一個整數n,輸出字串中取n個字元的所有組合情況演算法:藉助Next_permutation函數,構造一個大小為len=str.length()的數組,0表示要輸出的數,1表示不要輸出的數。代碼如下:#include <iostream>#include <string>#include <algorithm>#include <memory.h>
Time of Update: 2018-12-03
很大數量的數,求中位元思路:此題不能儲存所有元素,否則會MLE,想到用優先隊列(預設值大的優先順序高),儲存一半,剩下的一半依次和隊首比較,若小於隊首,則將隊首元素出隊,新元素入隊。最後,若n為奇數,隊首元素即為中間值;n為偶數,隊列前兩個的平均值為答案。#include <iostream>#include <cstdio>#include <algorithm>#include <vector>#include
Time of Update: 2018-12-03
題目:對1到N這些數進行排列,1在最左邊,相鄰的兩個數之差不能超過2,求有多少種排列方法?解法:dp[i] = dp[i-1] + dp[i-3] + 1;解釋:對dp[n],有3種情況:1、12……(dp[n-1])2、1324……(dp[n-3])3、1357……8642(一種確定的情況)代碼:#include <cstdio>using namespace std;int main(){ int N; scanf("%d",&N); int dp[56
Time of Update: 2018-12-03
Mr. F. wants to get a document be signed by a minister. A minister signs a document only if it is approved by his ministry. The ministry is an M-floor building with floors numbered from 1 to M, 1<=M<=100. Each floor has N rooms (1<=N<=500
Time of Update: 2018-12-03
1342.
Time of Update: 2018-12-03
jasison君我來無恥地抄(xue)寫(xi)代碼了~#include <cstdio>#include <cstring>struct Node{int a, b, cover;Node() {}Node(int _a, int _b): a(_a), b(_b), cover(0) {}int middle() { return (a+b)>>1; }} t[66000];void build(int a, int b, int d){t[d] =
Time of Update: 2018-12-03
看題傳送門吐槽題目 叫什麼很O_O的漢諾塔我還@。@呢。本來是想過一段時間在來寫題解的,不過有人找我要。本來排名是第8的。然後搞了半天,弄到了第五。不過代碼最短~截止目前就9個ID過,小小的成就感~PS用G++記憶體小。。。RankAuthorExe. TimeExe. MemoryCode Len.LanguageDate14bytes0MS204K1961BC++2011-07-30 22:15:192sunhaowen0MS212K895BG++2009-05-25
Time of Update: 2018-12-03
題意:給出一個串的長度n,串只有0,1組成,但是不能有兩個相鄰的1。按字典序給串排列,最先肯定是0000,接著是0001,依此類推。給一個數字m,輸出在長度為n的情況下,第m個排列的串是什麼,如果m大於總排列數,輸出-1思路:遞推。首先,計算滿足條件的N位序列的總個數。設為f[n]f[n]=f[n-1]+f[n-2]可是這樣理解:長度為N的序列對應於:1.長度為N-1的序列左邊加上02.長度為N-2的序列左邊加上10之後就類似求排列序號的方法。要明白以下這個事實:N位序列 0,a2,...an
Time of Update: 2018-12-03
/*思路是這樣的,f[t]=1表示還剩t個子時先手是能贏的,f[t]=0表示先手會輸,遞推公式是這樣的 f[t] = 1 若且唯若存在某個i,使f[t-k[i]]=0,因為先手可以直接拿k[i]個。*/#include <iostream>using namespace std;int main(){int n,m,i,j;cin>>n>>m;int* k = new int[m];int* f = new int[n+1];for
Time of Update: 2018-12-03
#include <iostream>#include <cstdio>#include <cstring>#include <queue>using namespace std;int map[105][105];int pay[105];int n;queue<int>Q;void init(){ memset(pay,-1,sizeof(pay)); memset(map,0,sizeof(map));