原创 4094. Spiral matrix

Given you a n*m matrix, you task is to output the corresponding Spiral matrix whose row is n and column is m. For exa

原创 dijstra算法 2870. The K-th City

這題的題意爲求距離爲第k長的編號,在這裏運用算法本身的性質,直接在算法中體現即可: —1.Dijkstra算法每次都是取出目前d值最小的頂點進行更新,即每次確定一個頂點u,即每次找到的結果都是到該點的最短路徑,而且第一次得到最短的、

原创 杭電 Largest prime factor

Problem Description Everybody knows any number can be combined by the prime number. Now, your task is telling me wha

原创 2219. A famous math puzzle

¡題目描述: 有n個壺,和無窮多的水.每次我們只能: 1.把其中一個壺灌滿. 2.把其中一個壺倒空. 3.把一個壺中的水倒入另一個壺中,直到一個壺爲空或者另一個壺已經滿了爲止. 給定一個體積W,問能否經過若干次倒水後使得最終有一個壺中只剩

原创 1909. Robot Motion

難度在於如何判斷循環~ A robot has been programmed to follow the instructions in its path. Instructions for the next direction

原创 堆的實現 2196. Nuanran's Idol II

堆用數組實現,時間複雜度爲O(logn),如果進一本書就排序一次的話時間複雜度很高。 You have known that nuanran is a loyal fan of Kelly from the last contest.

原创 杭電 Seinfeld

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1354    Accep

原创 杭電 1004 Let the Balloon Rise

用  strcmp(char a,char b)比較字符串是否相等, 相等爲0,頭文件爲#include<string.h> 注意:字符也可以有多維數組a[n][n]. Problem Description Contest tim

原创 3976. Change

After Shawn sees the following picture, he decides to give up his career in IT and turn to sell fruits. Since Shawn is

原创 杭電 1005

遞歸切記: 1.如果遞歸的次數大於100次,都很浪費時間,故應該考慮有沒有什麼規律; 2.遞歸時應該考慮循環節的情況。 對於此題,應當這麼看: 由於最後的結果是模7的,故f[n]可能的值只有7個,0~6,由於f[n]是由f[n-1]和f[

原创 杭電1267 下沙的沙子有幾粒?

題意:就是給你m個H和n個D,然後從左開始數H的累積個數總是不比D的累計數少的排列有多少種舉一個測試案例吧:3個H和1個D總共有3種排列,依次是:H D H H,H H D H,H H  H D三種排列,親~意思應該懂了吧?!呵呵。。。

原创 3259. Mysterious Number

Mysterious Number refers to a number which can be divisible by the number

原创 BFS 1056. Labyrinth

總是出現Runtime Error(SIGSEGV)這個錯誤,後來才發現了是數組越界,本來定義的二維數組,1000*1000,所以棧的數組要是1000*1000而不是1000,已經犯了好幾個這樣的錯誤了,該打,下次一定注意。 現在發現廣搜

原创 DFS 2273. Making Change

Grocery stores have long struggled with how to avoid long checkout lines that leave customers frustrated. The ��10 item

原创 杭電 Moving Tables

Problem Description The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in