HDU-1028-Ignatius and the Princess III

HDU-1028-Ignatius and the Princess IIIhttp://acm.hdu.edu.cn/showproblem.php?pid=1028整數劃分,無奈,逾時#include<stdio.h>int huafen(int n,int m)//將n分為最大加數不超過m{if(n<1||m<1)return 0;if(n==1||m==1)return 1;if(n<m)return huafen(n,n);if(n==m)return

POJ-2739-Sum of Consecutive Prime Numbers

POJ-2739-Sum of Consecutive Prime Numbershttp://poj.org/problem?id=2739判斷一個數能由多少種連續的素數構成,數目不大,先打表求出範圍內的所有素數#include<stdio.h>#include<string.h>#include<stdlib.h>#define N 10005char a[N];int b[N];int main(){int

joj2410: The knight problem

#include<iostream>#include<cstdio>#include<queue>using namespace std;typedef struct Point{ int x, y;}POINT;queue <POINT> me;POINT Begin , End;bool visited[9][9];bool flag;int ans;int movei[8]= {2,-2,1,-1,2,-2,1,-1};int

POJ -3126-Prime Path

POJ -3126-Prime Pathhttp://poj.org/problem?id=3126素數打表加BFS#include<iostream>#include<cstdio>#include<cstring>#include<cstdlib>#include<queue>using namespace std;#define N 10005int prime[10005];int visit[N];struct

HDU-1698-Just a Hook

HDU-1698-Just a Hookhttp://acm.hdu.edu.cn/showproblem.php?pid=1698還是成段更新線段樹#include<stdio.h>#include<string.h>#include<stdlib.h>#define N 100005struct cam{int x;int y;int sum;int val;}list[N*4];void build(int k,int x,int y){int mid;

HDU-3371-Connect the Cities

HDU-3371-Connect the Citieshttp://acm.hdu.edu.cn/showproblem.php?pid=3371最小產生樹,已知有些節點已經相連#include<stdio.h>#include<string.h>#include<stdlib.h>struct cam{int x;int y;int len;}list[25005*3];int f[505];int n,m,k;int find(int x){int

HDU-3074-Multiply game

HDU-3074-Multiply gamehttp://acm.hdu.edu.cn/showproblem.php?pid=3074求區間元素的乘積,可以更新元素,線段樹即可#include<stdio.h>#include<string.h>#include<stdlib.h>#define Mod 1000000007#define N 50005int num[N];struct cam{int x; //起點int y; //終點__int64

HDU-1596-find the safest road

HDU-1596-find the safest roadhttp://acm.hdu.edu.cn/showproblem.php?pid=1596SPFA演算法#include<iostream>#include<cstdio>#include<cstring>using namespace std;int n,m,st,ed,front,rear;double mat[1005][1005],dis[1005];int v[1005],q[1000001

HDU-1372-Knight Moves

HDU-1372-Knight Moveshttp://acm.hdu.edu.cn/showproblem.php?pid=1372求“馬”從一點到另一點的最短距離,馬走日,BFS即可#include<stdio.h>#include<string.h>#include<stdlib.h>int dir[8][2]={{-2,1},{-2,-1},{2,-1},{2,1},{-1,2},{-1,-2},{1,2},{1,-2}};int ans[10][10

HDU-1166-敵兵布陣(線段樹)

HDU-1166-敵兵布陣http://acm.hdu.edu.cn/showproblem.php?pid=1166求區間的和,並可更新,線段樹#include<stdio.h>#include<string.h>#include<stdlib.h>#define N 50005int num[N];struct cam{int x; //起點int y; //終點int sum; //總數}list[N*4];void build(int k,int

HDU-1010-Tempter of the Bone

HDU-1010-Tempter of the Bonehttp://acm.hdu.edu.cn/showproblem.php?pid=1010給這題折騰了半天啊,剛開始用BFS寫的,總是WA,後來發現這題要求在給定的時間點到達,不能早,也不能遲,而BFS每次求出的是最短時間,不合題意,於是轉用DFS,剪枝的方法是參考HDU的PPT寫的,居然還要考慮奇偶性可以把map看成這樣: 0 1 0 1 0 1 1 0 1 0 1 0 0 1 0 1 0 1 1 0 1 0 1 0 0 1 0 1 0

HDU-4068-SanguoSHA

HDU-4068-SanguoSHAhttp://acm.hdu.edu.cn/showproblem.php?pid=4068字串類比,枚舉自己和對手的牌的全排列即可#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int map[10][10];char str[10][25];int

HDU-1754-I Hate It

HDU-1754-I Hate Ithttp://acm.hdu.edu.cn/showproblem.php?pid=1754查詢區間的最大值,並可以更新線段樹即可,為區間[1,5]的線段樹#include<stdio.h>#include<string.h>#include<stdlib.h>#define N 200005int num[N];struct cam{int x; //起點int y; //終點int max;

HDU-4325-Flowers

HDU-4325-Flowershttp://acm.hdu.edu.cn/showproblem.php?pid=4325成段更新加離散化線段樹這題做了快有一天了。。。。各種問題啊,開始建樹時沒有把查詢的節點加入樹中,結果在查詢時發現很多節點的資訊丟失了,糾結了半天去看了下別人的代碼,原來建樹時就應把查詢的節點加入,在做離散化時,將hash數組開到10^9,又超記憶體了,通不過編譯,囧,之後改成map映射,終於羞愧的A了(這題的資料可能比較弱,不加離散化也能過)#include<iost

HDU-1244-Oil Deposits

HDU-1244-Oil Depositshttp://acm.hdu.edu.cn/showproblem.php?pid=1241基本的DFS#include<stdio.h>#include<string.h>#include<stdlib.h>char map[105][105];int n,m;int dir[8][2]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};int

HDU-1305-Immediate Decodability

HDU-1305-Immediate Decodabilityhttp://acm.hdu.edu.cn/showproblem.php?pid=1305字典樹水題,判斷首碼#include<iostream>#include<cstdio>#include<cstring>#include<cstdlib>using namespace std;struct node{int count;node *childs[2];node(){count=

HDU-3790-最短路徑問題

HDU-3790-最短路徑問題http://acm.hdu.edu.cn/showproblem.php?pid=3790單源最短路勁,更新路勁時要更新花費#include<iostream>#include<cstdio>#include<cstring>#include<cstdlib>using namespace std;#define INF 0x7fffffffint n,m;int map[1005][1005];int cost[1

POJ-1321-棋盤問題

POJ-1321-棋盤問題http://poj.org/problem?id=1321基本的DFS#include<stdio.h>#include<string.h>#include<stdlib.h>int n,t,ans;char map[10][10];int visit[10];void dfs(int x,int y){int i;if(y==t){ans++;return;}if(x>=n)return;

HDU-2795-Billboard

HDU-2795-Billboardhttp://acm.hdu.edu.cn/showproblem.php?pid=2795線段樹,建樹時要注意範圍#include<iostream>#include<cstdio>#include<cstring>#include<cstdlib>using namespace std;#define N 200005int h,w;struct cam{int x;int y;int

HDU-2612-Find a way

HDU-2612-Find a wayhttp://acm.hdu.edu.cn/showproblem.php?pid=2612求2個點到KFC的距離之和,使其最小,可用2次BFS,分別求出2個點到各個KFC的最短距離,然後找出和最小的即可#include<stdio.h>#include<string.h>#include<stdlib.h>#define max 0x7fffffffint n,m;char map[250][250];int

總頁數: 61357 1 .... 13477 13478 13479 13480 13481 .... 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.