UVA 673 Parentheses Balance

Description  Parentheses Balance You are given a string consisting of parentheses () and []. A string of this type is said to be correct:(a)if it is the empty string(b)if A and B are correct, AB is correct,(c)if A is correct, (A) and [A] is

HDOJ 4228 Flooring Tiles (反素數)

~~~題目連結~~~題目大意:現有若干面積相同的小正方行, 給出n種面積相同的長方行, 問用最少用多少個正方行能恰好拼出n種長方行, 如n = 2, 這時最少用4個正方行可拼出2中長方形, 分別是1*4, 和2*2面積相同的長方形。定義  對於任何正整數x,其約數的個數記做g(x).例如g(1)=1,g(6)=4.如果某個正整數x滿足:對於任意i(0<i<x),都有g(i)<g(x),則稱x為反素數.性質  性質一:一個反素數的質因子必然是從2開始連續的質數.  性質二:p=2

POJ 2305 Basic remains (大數餘)

~~~題目連結~~~code:#include <stdio.h>#include <string.h>#include <iostream>#include <cmath>using namespace std;int a = 0, b = 0, k = 0, x = 0, y = 0;void translate1()//把k進位的數轉化為10進位{ int cnt = 0; x = y = 0;

POJ 1050 To the Max

~~~題目連結~~~題目大意:現給出一個矩陣, 現在求這個矩陣中子矩陣最大和是多少思路:子矩陣是連續的一塊, 可以把它看成一個整體, 如矩陣第1第2行相加合并後成為單獨的一行, 對這行求最大連續和就是求這2行矩陣的子矩陣和最大code:#include <stdio.h>#include <string.h>#define inf -0x7fffffffusing namespace std;int n = 0, max = 0, map[102][102];int

POJ 1018 Communication System (枚舉)

~~~題目連結~~~題目大意:現有n個通訊點, 要從n家通訊商那,每個通訊商中選出一個裝置, 要求所選裝置的頻寬中最小的做為最小頻寬B, 總價格為P, 現在要求求出B/P的值最大思路:依次枚舉B能到的值code:#include <stdio.h>#include <algorithm>#define inf 0x7fffffffusing namespace std;struct node{ int w, v;}p[102][102];int main(){ /

HDOJ 1003 Max Sum

~~~題目連結~~~思路:前幾個數的連續和加上當前這個數, 如果比當前這個數小就從當前這個位開鎖重新記區間,否則加入當前區間,注意有負數, 不能用連續的幾個數和小於0做結束判斷 code:#include <iostream>#include <algorithm>using namespace std;int main(){ int i = 0, j = 0, t = 0, x = 0, y = 0, cnt = 0, ans = -0x7fffffff,

HDU 1272 小希的迷宮

Description上次Gardon的迷宮城堡小希玩了很久(見Problem

HDU 1130 How Many Trees?

Problem DescriptionA binary search tree is a binary tree with root k such that any node v reachable from its left has label (v) <label (k) and any node w reachable from its right has label (w) > label (k). It is a search structure which can

HDU 1158 Common Subsequence

Problem DescriptionA subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = <x1, x2, ..., xm> another sequence Z = <z1, z2, ..., zk> is a subsequence of X if there exists a

HDOJ 1394 Minimum Inversion Number (逆序數對)

~~~題目連結~~~題目大意:給出一個序列, 要求求出這個序列和他經過環移後, 逆序數對中最小的一個。思路;用線段樹求逆序數, 每當加入一個數x時, 就求x~n-1有多少個數出現過, 出現多少就是多少逆序數對。求出一組序列後, 環移後的逆序數對可以用公式求出, 環移用STL實現code:#include <stdio.h>#include <string.h>#include <algorithm>#define N 5002using namespace

HDOJ 1698 Just a Hook

~~~題目連結~~~題目大意:現給出一個區間, 剛開始時區間中的每個點對應的值為1, 現在更新q次, 把x-y區間的點的值全跟新為z, 現在求出整個區間點的值的和。思路:線段樹, 跟新每個區間時只更新到覆蓋的區間, 下回更新時再通過cv【】數組往下更新。code:#include <stdio.h>#include <string.h>#define N 100002using namespace std;int n = 0, x = 0, y = 0, z = 0,

UVA 297 Quadtrees (4叉樹)

~~~題目連結~~題目大意:根據題目的要求可以把矩形(32*32)轉換成4叉樹, 現在給出2個矩形, 2個矩形相加求出第三個矩形,然後求第三個矩形黑色像素所佔的面積。 code:#include <iostream>using namespace std;typedef struct node{    char ch;    struct node *nt[4];}Node;int ans = 0;void build(int &cur, Node *r, string

UVA 112 Tree Summing

~~題目連結~~題目大意:用()表示空節點, (5)表示一個為5的節點, 5()() 表示葉子節點, 5(2)(6)表示當前節點為5, 左節點為2,右節點為6.現在給出一串字串, 求是否有根節點到分葉節點的值等於給定的值。code:#include <iostream>#include <algorithm>using namespace std;typedef struct node{ int num; struct node *lf, *rt;}Node;

HDU 1060 Leftmost Digit

Problem DescriptionLarry graduated this year and finally has a job. He’s making a lot of money, but somehow never seems to have enough. Larry has decided that he needs to grab hold of his financial portfolio and solve his financing problems. The

vijos P1033 整數分解(版本2)

~~~題目連結~~~思路:3 = 1+24 = 2+25 = 2+36 = 3+37 = 2+2+38 = 2+3+39 = 3+3+310 = 2+2+3+3..........通過分解發現把一個數分解成儘可能多的2與3就為最大值。code:#include <stdio.h>#include <string.h>#include <math.h>using namespace std;struct node{ int num[1002];

POJ 1405 Heritage

DescriptionYour rich uncle died recently, and the heritage needs to be divided among your relatives and the church (your uncle insisted in his will that the church must get something). There are N relatives (N <= 18) that were mentioned in the

vijos p1024 卡布列克圓舞曲

描述 Description  卡布列克是一位元學家,他在研究數字時發現:任意一個不是用完全相同數字組成的四位元,如果對它們的每位元字重新排序,組成一個較大的數和一個較小的數,然後用較大數減去較小數,差不夠四位元時補零,類推下去,最後將變成一個固定的數:6174,這就是卡布列克常數。  例如:4321-1234=3087     8730-378=8352     8532-2358=6174    

QT登陸視窗代碼

#include "dialog.h"#include "ui_dialog.h"#include "QtGui"#include "mysql/mysql.h"#include<cstdio>#include<cstring>#include<string>using namespace std;Dialog::Dialog(QWidget *parent) :QDialog(parent),ui(new Ui::Dialog){

看完這個你的位元運算學得就差不多了

位元運算應用口訣 清零取反要用與,某位置一可用或 若要取反和交換,輕輕鬆鬆用異或 移位元運算 要點 1 它們都是雙目運算子,兩個運算分量都是整形,結果也是整形。     2 " < <" 左移:右邊空出的位上補0,左邊的位將從字頭擠掉,其值相當於乘2。     3 ">>"右移:右邊的位被擠掉。對於左邊移出的空位,如果是正數則空位補0,若為負數,可能補0或補1,這取決於所用的電腦系統。     4

POJ 2387 Til the Cows Come Home

DescriptionBessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep, so she wants to get back as quickly as possible. Farmer

總頁數: 61357 1 .... 19244 19245 19246 19247 19248 .... 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.