codeforces 322 A Ciel and Dancing

題目連結題意:      有n個男孩和m個女孩,他們要結對跳舞,每對要有一個女孩和一個男孩,而且其中一個要求之前沒有和其他人結對,求出最大可以結多少對。,一條線代表一對,只有這樣三種情況。#include <iostream>#include <algorithm>#include <stdio.h>using namespace std;int main(){ int n, m; while (cin >> n >> m)

codeforces 322 B Ciel and Flowers

題目連結有紅綠藍三種顏色的畫,每種拿三朵可以組成一束花,或者各拿一朵組成花束,告訴你每種花的數目,求出可能組成最多的花束。如果你的代碼過不了,考慮一下 8 8 9這種組合。  因為資料量很大,我的思想就是局部和總體採用不同的策略。#include <iostream>#include <algorithm>using namespace std;int main(){ int r, g, b; while (cin >> r >> g

poj 1068 類比

題目連結    大概題意就是告訴你有個n個小括弧,每一個“)”左邊有多少個“(”都告訴你了,然後讓你求出每一對括弧之間有多少對括弧(包含自己本身)。思路:       我先計算每個“)”左邊有多少個“(”要匹配,然後每遇到一個“)”,然後向前尋找第一個可以匹配的“(”,找到後將其數量減一,這樣的話在尋找的過程中經過了幾個“)”就表示這對括弧裡面有多少括弧。//poj 1068//2013-07-17-08.45#include <iostream>#include

codeforces 327 A Ciel and Dancing

題目連結    給你一串只有0和1的數字,然後對某一區間的數翻轉1次(0變1 1變0),只翻轉一次而且不能不翻轉,然後讓你計算最多可能出現多少個1。    這裡要注意很多細節 比如全為1,要求必須翻轉,這時候我們只要翻轉一個1就可以了,對於其他情況,我們只要計算區間裡面如果0多於1,將其翻轉後計算1的總數,然後取最大值。//cf 191 A//2013-07-04-22.13#include <stdio.h>#include <string.h>#include

HDOJ搜尋題輯錄I(總計100題)

DFS(Depth First Search )一般是不用hash的,所以很多時候稱之為”暴力”,也就是窮舉所有情況,一般看幾個我們OJ的dfs的版本的題目就可以模仿著做了,因為牽涉到遞迴,初學者學的時候最好能舉一反三,理解其中真諦.DFS --- EASY(15) Tempter of theBone Safecracker Prime RingProblem Robot Motion Fire Net 猜數字                                          

Codeforces Round #192 (Div. 2) (330A) A. Cakeminator

題意:       如果某一行沒有草莓,就可以吃掉這一行,某一列沒有也可以吃點這一列,求最多會被吃掉多少塊蛋糕。//cf 192 div2#include <stdio.h>#include <string.h>int vis[11][11];char map[11][11];int main(){ int r, c; while (scanf("%d %d", &r, &c) != EOF) { for (int i =

HDU 1016 Prime Ring Problem 搜尋

#include<cstdio>#include<iostream>#include<cstring>#include<set>using namespace std;int cir[25],n;bool vis[25];set<int>st;bool isprime(int n){ for(int i=2; i*i<=n; i++) if(n%i==0) return false;

poj 2479 Maximum sum(求最大子段和的延伸)

題目連結題意:       題目的大概意思是把數組分成不交兩段,分別求出兩段的最大子段和s1和s2,然後求出最大的s1+s2。不知道最大子段和的點這  here思路:      看完最大連續子段和 的 dp演算法 這個很容易理解,我用dplift[i]儲存第1到第i個之間的最大子段和,dpright[i]儲存第i到第n個之間的最大子段和,最終結果就是dplift[i]+dpright[i+1]中最大的一個。代碼//poj 2479 Maximum

HDU1102 Constructing Roads 最小產生樹

           基本算是最小產生樹的模板題,對於已經建好的路,把它的長度標記為0就可以了。這個題比較坑的地方是輸入是有多組資料的,還有數組越界有可能返回的是WA,注意數組的大小。如果全部存下,應該是n*n+n*(n+1)/2.#include<cstdio>#include<iostream>#include<cstring>#include<set>#include<algorithm>#define MAXN

HDU 1009 貪心

                  一開始以為浮點數有精度損失,在輸出那裡寫 printf("%.3lf\n",sum+0.0001);結果WA了。不需要考慮精度損失。#include<cstdio>#include<iostream>#include<cstring>#include<set>#include<algorithm>#define MAXN 5010using namespace std;struct Node{

URAL 1200. Horns and Hoofs 枚舉+數學

           

【DP_背包專輯】【4.04最新更新】

(解題報告本人所寫,部落格內容轉自zeroclock)這短時間看了論文《背包九講》,看到背包問題解法中的優美之處也看到背包問題在現實中的應用,總結出一句話:背包問題值得一看。   

HDU 1054Strategic Game 貪心

           

codeforces 283A – Cows and Sequence 簡單資料結構類比

           

Codeforces 218B Airport

B. Airporttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLolek and Bolek are about to travel abroad by plane. The local airport has a special "Choose Your Plane" offer. The offer's conditions

Codeforces Round #180 (Div. 2) 解題報告

題目連結A.Snow FootprintsA - Snow FootprintsThe starting position can be anywhere with a footprint. The footprints can be categorized into 3 types.only L sonly R sR s followed by L sIn case 1, we end in the left of all footprints. In case 2, we end in

poj2983 Is the Information Reliable?

Is the Information Reliable?Time Limit: 3000MS Memory Limit: 131072KTotal Submissions: 9905 Accepted: 3072DescriptionThe galaxy war between the Empire Draco and the Commonwealth of Zibu broke out 3 years ago. Draco established a line of defense

poj 1011 hdoj 1455 Sticks(搜尋+剪枝)

題目連結大致題意:有n跟棍, 求它們能組成最短且長度相同的棍的長度 解題思路:DFS+剪枝 POJ2362的強化版,重點在於剪枝   建議你先看看這道題  here 令initlen為所求的最短原始棒長,maxlen為給定的棒子堆中最長的棒子,sumlen為這堆棒子的長度之和,那麼initlen必定在範圍[maxlen,sumlen]中,cnt為可能組成的數目,也就是sunlen/maxlen。 根據棒子的靈活度(棒子越長,靈活度越低) DFS前先對所有棒子降序排序 剪枝:1、 

codeforces 327 B. Hungry Sequence

題目連結   題目就是讓你輸出n個數的序列,要保證該序列是遞增的,並且第i個數的前面不能保護它的約數,我直接先對前100000的素數打表,然後輸出前n個,so easy。//cf 191 B#include <stdio.h>#include <string.h>int ans[100005];bool vis[10000000];int main(){ int cnt = 1; for (int i = 2; i < 1300000; i++)

hdu2126 Buy the souvenirs 01背包變形 dp

連結:點我題意:n個物品,m元錢,每個物品最多買一次,問最多可以買幾件物品,並且輸出方案數。加一維表示已經買幾件物品。我這裡用了一個數組dp[v][2] ,dp[v][0] 儲存原本要記錄的 dp ,而 dp[v][1] 則記錄方案數目。記住需要初始化,把所有 dp[i][1] 都設定成1。#include <cstdio>#include <cstring>#include <iostream>using namespace std;#define max(

總頁數: 61357 1 .... 15141 15142 15143 15144 15145 .... 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.