Poj 2823 (單調隊列裸題)

Sliding WindowTime Limit: 12000MS Memory Limit: 65536KTotal Submissions: 32104 Accepted: 9528Case Time Limit: 5000MSDescriptionAn array of size n ≤ 106 is given to you. There is a sliding window of sizek which is moving from the very left of the

浙大oj 1294 golf

#include "stdio.h"int main (){ int  p,s,c=0; while(1) {  c++;  scanf("%d%d",&p,&s);  if(p==0)break;  if(s==1)   printf("Hole #%d\nHole-in-one.\n\n",c);  else  {   if(s-p==-3)    printf("Hole #%d\nDouble

F. Letter Grid 動態規劃問題

F.         Letter GridConsider the following letter grid:E     R    A    T      ATSRAUTUThere are 7 ways to read the word TARTU fromthe grid:E   R   A   T   ATSRAUTUE     R     A    T   ATSRAUTUE     R     A    T     ATSRAUTUE    R    A    T    

HDOJ1326 Box of Bricks

#include<stdio.h>#include<stdlib.h>using namespace std;#define NUM 50 +5int main(){ int n,total,average,step,hgt[NUM]; int i,count=1; while(scanf("%d",&n),n){ memset(hgt,0,sizeof(hgt)); total=0;

UVA10025 The ? 1 ? 2 ? … ? n = k problem

這道題剛開始抓破頭腦也想不出怎麼做。後來從0到10寫了一遍就發現了一些規律。若且唯若n滿足如下情況才是我們要求的n:(1):sum=1+2+3+.....+n>=k(2):(sum-k)%2==0(即sum與k的差為偶數。)(3):對於任何m<n,m不同時滿足上面兩條。(即保證n是最小的那個數)第一條很顯然,第二條略加證明如下:因為sum>k,所以一定有sum-x=k,即1+2+3+......+n-x=k,1+2+3++...-x/2+...+n-x/2=k,因為x/2一定是

zoj3204||poj3450 最小產生樹

//zoj3204||poj3450 最小產生樹,要求字典序最小的先輸出//需要輸出邊的頂點的一類題用prim不會啊,請大神指點一下//還要注意輸出行末尾不能有空格#include"stdio.h"#include"stdlib.h"#include"limits.h"#define N 102typedef struct side{int e,s,len;}side;side sides[N*N];int n,cases,g[N][N],has[N*N];int input(){int i,

UVA10161 Ant on a Chessboard

這道題目也是找到規律就不難了。基本思想:注意到中間斜對角線數是有規律的。輸入n,再根據n的大小從對角線上的數開始來找。這裡要注意此時對角線上的數橫座標的奇偶性,分兩種情形討論。//b.cpp#include<stdio.h>int main(){ int n,m,x,y,i; while(scanf("%d",&n),n){ m=1; i=1; do{

hdu 1240 Asteroids BFS

三維矩陣的BFS思想挺簡單可是在建圖的過程中有一點沒想到結果WA了4次啊,,,,,,注意這樣才正確for(int i=1;i<=n;i++)for(int k=1;k<=n;k++)for(int p=1;p<=n;p++)cin>>map[p][k][i];而這樣就不對了for(int i=1;i<=n;i++)for(int k=1;k<=n;k++)for(int p=1;p<=n;p++)cin

HDOJ2048 神、上帝以及老天爺(錯排問題)

這道題要用到錯排的知識,剛開始也不會。後來到網上找資料惡補了一下就A掉了。哈哈。錯排的相關知識可以參考我的部落格:http://blog.folyd.com/archives/39//hdoj2048.cpp#include<iostream>using namespace std;int main(){ int t,n,i; double p; double a[21],b[21];//定義了兩個數組,數組a表示錯排數,數組b表示階乘 a[1]=0.00;

HDOJ2068 RPG的錯排

    這道題也要用到錯排的知識。   題目只要求他答對一半或以上就算過關,換句話說就是猜對了一半以上,其他的全部算是錯排。所以就是求1~n/2每項的錯排數再乘以組合數(函數c(n,m)求組合數)之和。  HDOJ2049這道題也是這個類型的//hdoj2068.cpp#include<iostream>using namespace std;__int64 c(int n,int m){ int a=1; if(m==0)

zoj2326Tangled in Cables

//zoj2326Tangled in Cables//用給定長度的繩子將村裡的房屋連起來,房屋可視為點//每一對房屋之間只有一條路,我用的是Kruscal//zoj的平台好強大。。。。。。//cmp函數定義傳回值為整數,當我返回實數時//(return(p1->length-p2->length))就WA。。囧//if(p1->length>p2->length)// return 1;// else return

HDOJ1002 A + B Problem II

原諒我我這個時候才A掉這道經典的大數題目,因為用C++嘗試了三四次一直A不掉,最後還是用Java  A掉的。杭電OJ上用Java A題時要注意到一點的是類名必須是Main ,要不然會編譯錯誤。import java.util.Scanner;import java.math.BigInteger;public class Main{public static void main(String[]args){Scanner scanner=new

Poj 3494 (dp)

Largest Submatrix of All 1’sTime Limit: 5000MS Memory Limit: 131072KTotal Submissions: 4546 Accepted: 1700Case Time Limit: 2000MSDescriptionGiven a m-by-n (0,1)-matrix, of all its submatrices of all 1’s which is the largest? By largest we mean that

浙大OJ 1733 Common Subsequence

#include"stdio.h"#include"string.h"#define MAX  1000void LCSLength(int m,int n,char x[],char y[],int c[][1000]){   int i,j; for (i = 0; i <=m; i++)   for (j= 0; j<=n; j++)    c[i][j] = 0; for (i = 1; i <=m; i++)  for (j = 1; j <=n; j++)  

Poj 3279 & 1222(開關問題)

FliptileTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 2648 Accepted: 1022DescriptionFarmer John knows that an intellectually satisfied cow is a happy cow who will give more milk. He has arranged a brainy activity for cows in which they

HDOJ2030 漢字統計 (漢字機內碼特點)

這道題只要明白漢字機內碼的特點就很容易了。漢字機內碼在電腦的表達方式的描述是,使用二個位元組,每個位元組最高位一位為1。 電腦中, 補碼第一位是符號位, 1 表示為 負數,所以 漢字機內碼的每個位元組表示的十進位數都是負數統計輸入字串含有幾個漢字,只只需求出字串中小於0的字元有幾個,將它除以2就得到答案。Post Code:#include<iostream>using namespace std;int main(){

Poj 3185(開關問題)

The Water BowlsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 3790 Accepted: 1483DescriptionThe cows have a line of 20 water bowls from which they drink. The bowls can be either right-side-up (properly oriented to serve refreshing cool

Poj 2229(dp)

SumsetsTime Limit: 2000MS Memory Limit: 200000KTotal Submissions: 10974 Accepted: 4419DescriptionFarmer John commanded his cows to search for different sets of numbers that sum to a given number. The cows use only numbers that are an integer power

hdu2680-最短路徑—Dijkstra

第一次提交逾時了;終點只有一個,起點有多個,想多次Dijkstra來著,結果毫無懸念地逾時瞭然後想起周三劉學長說多的一點------貌似就是超級匯點(為了借題需要虛構出的一個頂點)使編號為0的虛擬超級匯點,到各個起點有一條單向的,權值無為0的邊然後從超級匯點開始尋找,這樣只需一次Dijkstra就OK了#include<iostream>using namespace std;const int N=1005;const int maxint=100000000;int map[N]

Poj 2385 (dp)

Apple CatchingTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 6381 Accepted: 3096DescriptionIt is a little known fact that cows love apples. Farmer John has two apple trees (which are conveniently numbered 1 and 2) in his field, each full

總頁數: 61357 1 .... 13456 13457 13458 13459 13460 .... 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.