1154. Easy sort

1154. Easy sortDescriptionYou know sorting is very important. And this easy problem is:Given you an array with N non-negative integers which are smaller than 10,000,000, you have to sort this array. Sorting means that integer with smaller value

2014. Dairy Queen

soj.me/2014動態規劃// Problem#: 2014// Submission#: 1211589// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/// All Copyright reserved

1639. Run Length Encoding

坑爹啊有Null 字元串的情況,PE了好多次。#include <iostream>#include <string>#include <cctype>using namespace std;int main(){string s;while(getline(cin,s)){if(s==""){cout<<endl;continue;}int count=0,len=s.length();bool b=true;for(int

1388. Quicksum

1388. QuicksumDescriptionA checksum is an algorithm that scans a packet of data and returns a single number. The idea is that if the packet is changed, the checksum will also change, so checksums are often used for detecting transmission errors,

1587. Eat or Be Eaten

soj.me/1587#include <iostream>#include <algorithm>#include <cstring>using namespace std;int a[20001],b[20001];int cmp(int a,int b){return a<b;}int f(int min,int max,int t){int mid=(min+max)/2;if(b[max-1]<t)return max;else

1035. DNA matching

1035. DNA matchingDescriptionDNA (Deoxyribonucleic acid) is founded in every living creature as the storage medium for genetic information. It is comprised of subunits called nucleotides that are strung together into polymer chains. DNA polymer

1321. Robot (dijkstra)

#include <iostream> //優先順序隊列實現dijkstra演算法很方便#include <cstring>#include <queue>using namespace std;class Path{public: int i, j; int dist; Path( int a, int b, int c ) { i = a; j = b; dist = c; } friend bool

2038. String Reversion

2038. String ReversionDescription Given a valid identifier in C programs, please write a program to reverse it by respectively reversing two parts separated by ‘_’.Input The first line is an integer m, indicating the number of test cases.Then there

1114. Food Cubes (3D bfs)

#include <stdio.h>#include <memory.h>const int N=102;const int nei[6][3]={ { 0, 0, 1}, { 0, 0,-1}, { 1, 0, 0}, {-1, 0, 0}, { 0, 1, 0},

Sicily 1889. Max’s game (優先隊列dijkstra、雜湊)

// 題意: 有n*m矩陣,從起點(sx,sy)出發,可以上下左右四個方向移動,// 若兩個位置上是相同字元,則花費為0,否則為1,求到終點的最短距離// 用Dijkstra演算法解決,但會 TLE ,需要用 優先隊列 最佳化時間#include <iostream> // 鄰接矩陣+優先隊列實現Dijkstra演算法#include <stdio.h>#include <queue>#include <cstring>using

VC6.0編譯器不符合標準的一些情況(解決一些編譯錯誤)

都什麼時代了,老譚的書還用VC6.0, 編譯器那麼老(好像是c89之前了,比較新的是c99標準)對標準支援不好,真是阻礙中國電腦教育的進步。最近幾個編譯器來回換,藍橋杯好像只給vc6.0,發現還是g++的編譯器比較好,編譯出的代碼執行速度更快一點,對標準支援的最好。看這一段很簡單的代碼: 1 #include <iostream> 2 #include <cstdio> 3 using namespace std; 4 int main() 5 { 6 int

1135. 飛越原野 (bfs) ★

#include <iostream>#include <queue>#include <string>using namespace std;int dir[4][2]={1,0,-1,0,0,1,0,-1};int n,m,d,ans,g[102][102][102],head,tail; //g(xyz)表示到(x,y)後還可以飛z步的最優解bool p[102][102],vis[102][102][102];

1703. Obstacle Course(最短路徑bfs)

給定經過矩陣每個cell的代價,求從0,0到n-1,n-1最小代價#include <iostream>#include <queue>#include <cstring>using namespace std;queue<int> q;int N,ipt[200][200],dis[200][200],dx[]={-1,1,0,0},dy[]={0,0,-1,1};void bfs(){int

1781. Knight (bfs)

#include <iostream>#include <queue>#include <cstring>using namespace std;queue<int> q;int vis[520][520],dis[520][520],dx[]={-2,-2,-1,-1,1,1,2,2},dy[]={-1,1,2,-2,2,-2,1,-1};int main(){int

hdu 1016 Prime Ring Problem (dfs)

http://acm.hdu.edu.cn/showproblem.php?pid=1016 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 bool isp[40], vis[20]; //isp[]素數標記數組 5 int n, a[20]; 6 bool is_prime(int n)

1036. Crypto Columns

1036. Crypto ColumnsDescriptionThe columnar encryption scheme scrambles the letters in a message (or plaintext) using a keyword as illustrated in the following example: Suppose BATBOY is the keyword and our message is MEET ME BY THE OLD OAK TREE.

poj1733 & Ural 1003 Parity Game (hash+並查集 )

長度為n的0和1組成的字串, 然後問第L和R位置之間有奇數個1還是偶數個1.根據這些回答, 判斷第幾個是錯誤(和之前有矛盾)的。一旦發現有矛盾了,要馬上跳出迴圈, 後面的那些資料不用去管他了,否則如果用continue就WA。#include <iostream>#include <map>#include <cstring>using namespace std;const int MAXX=10005;int

Ural 1016. Cube on the Walk (bfs滾骰子)

題意:個立方體放在國際象棋棋盤的一個格子上,該立方體每一面都和棋盤的格子一樣大。該立方體每一面都標有一個非負整數。你可以在棋盤上滾動該立方體,在這期間計算立方體底面數位和。你的任務是找出一條從給定的起點到終點的路徑,使得前面所說的和最小。比較麻煩的題。#include<iostream> #include<algorithm> #include<cstring> #include<fstream> #include<queue>

hdu 1024 Max Sum Plus Plus (最大m子段和)(經典DP)

給定由n個整數(可能為負整數)組成的序列e1,e2,…,en,以及一個正整數m,要求確定序列的m個不相交子段,使這m個子段的總和達到最大。分析:設b(i,j)表示數組e的前j項中i個子段和的最大值,且第i個子段含e[j](1£ i £m,i£ j £n)。以下稱b(i, j)為“最後一個元素屬於第i子段的j元素i子段問題”。則n個元素中求i個子段的最優值顯然為:best(i, n) = Max{ b(i, j) } (i <= j <=

hdu 1072 Nightmare(dfs))

這個代碼思路比較清晰。大意:在n×m的地圖上,0表示牆,1表示空地,2表示人3表示目的地,4表示有炸彈重啟器。炸彈的時間是6,人走一步所需要的時間是1。每次可以上、下、左、右移動一格。當人走到4時如果炸彈的時間不是0,可以重新設定炸彈的時間為6。如果人走到3而炸彈的時間不為0時,成功走出。求人從2走到3的最短時間。這裡當走過了4以後就不要重新返回到4,我們把4設為0不能再走;其餘的走過後,不進行標記,也就是說他後面還有可能走到這個位置,可能會出現死迴圈,然而事實不是如此,還沒等到你出現,他就re

總頁數: 61357 1 .... 18757 18758 18759 18760 18761 .... 61357 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.