![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法竞赛入门经典(第二版)----暴力求解法
文章平均质量分 78
wang2147483647
这个作者很懒,什么都没留下…
展开
-
UVA 1354(p197)----Mobile Computing
#include#define debuusing namespace std;const int maxn=10;struct point{ double l,r; point(double a=0.0,double b=0.0):l(a),r(b) {}};double r;int n,t,v[1<<maxn];vector tree[1<<maxn];do原创 2016-02-26 00:21:53 · 298 阅读 · 0 评论 -
UVA 225(p214)----Golygons
#include#include#include#include#define debuusing namespace std;const int maxn=220;const int dx[4]= {1,0,0,-1};const int dy[4]= {0,1,-1,0};const char dir[]= {'e','n','s','w'};int t,n,k,ans;原创 2016-02-25 22:39:00 · 439 阅读 · 0 评论 -
UVA 524(p194)----Prime Ring Problem
#include#include#include#includeusing namespace std;int v[200],a[20],prime[100],n,cas=0,num;void prepare(){ memset(v,0,sizeof(v)); num=1; for(int i=2; i<=100; i++) { if(原创 2016-02-25 23:01:16 · 256 阅读 · 0 评论 -
UVA 725(p182)----Division
#include#include#includeusing namespace std;typedef long long LL;int n,cc[10],dd[10],cas=0;LL temp1,temp2;bool flag;bool check(LL a,LL b){ int top1=0,top2=0; memset(cc,0,sizeof(cc));原创 2016-02-25 23:19:10 · 651 阅读 · 0 评论 -
UVA 307(p218)----Sticks
#include#include#include#include#define debuusing namespace std;const int maxn=1e7;int n,l,sum;int a[maxn];int v[maxn];int cmp(int a,int b){ return a>b;}int dfs(int len,int num,int po原创 2016-03-26 19:19:43 · 402 阅读 · 0 评论 -
UVA 1374(p211)----Power Calculus
#include#include#include#define debuusing namespace std;const int maxn=1e4+50;int n;int a[maxn];int solve(int dep,int maxd,int now){ if(dep>maxd) return 0; if(now==n) { pr原创 2016-03-26 19:31:20 · 478 阅读 · 0 评论 -
UVA 1343(p210)----The Rotation Game
#include#define debuusing namespace std;int cmd[8][7]={ {0,2,6,11,15,20,22}, {1,3,8,12,17,21,23}, {10,9,8,7,6,5,4}, {19,18,17,16,15,14,13},};const int opp[8]= {5,4,7,6,1,0,3,2};原创 2016-03-26 19:35:16 · 518 阅读 · 0 评论 -
UVA 11214(p217)----Guarding the Chessboard
#include#include#include#define debuusing namespace std;const int maxn=50;int v[5][100];int g[15][15];int n,m,cas=0;int check(){ for(int i=0; i<n; i++) for(int j=0; j<m; j++)原创 2016-03-26 19:40:44 · 648 阅读 · 0 评论 -
UVA 10384(p219)----The Wall Pusher
#include#define debuusing namespace std;const int dx[]= {0,-1,0,1};const int dy[]= {-1,0,1,0};const int d[]= {1,2,4,8};const char dir[]= {"WNES"};int stx,sty;int g[10][20];int v[10][20];char原创 2016-03-26 19:48:00 · 620 阅读 · 0 评论 -
UVA 211(p215)----The Domino Effect
#include#include#include#include#define debuusing namespace std;const int maxn=50;const int dx[2]= {0,1};const int dy[2]= {1,0};int v[maxn];int cas=0,num;int m[maxn][maxn];int flag[maxn][m原创 2016-02-25 22:36:23 · 573 阅读 · 0 评论 -
UVA 208(p214)----Firetruck
#include#include#include#includeusing namespace std;int g[100][100],v[100],en,n,a[100],sum,m[100][100];void floyd(){ for(int k=1; k<=n; k++) for(int i=1; i<=n; i++) for(原创 2016-02-25 22:32:43 · 492 阅读 · 0 评论 -
UVA 1601(p205)----The Moring after Halloween
#include#define debuusing namespace std;const int maxn=500;const int dx[4]= {0,0,-1,1};const int dy[4]= {1,-1,0,0};string st[20];vector g[maxn];int v[maxn][maxn][maxn];int q[5000][4],d[4],n,m原创 2016-02-26 13:38:29 · 272 阅读 · 0 评论 -
UVA 10603(p202)----Fill
#includeusing namespace std;const int maxn=200+50;int ans[maxn];int cap[3],t,a,b,c,d;int v[maxn][maxn];struct point{ int v[3],dist; bool operator < (const point& rhs) const {原创 2016-02-26 14:22:57 · 230 阅读 · 0 评论 -
UVA 10976(p183)----Fractions Again?!
#include#includetypedef struct{int x,y;}point;point ans[10000];int top,n;void output(){ printf("%d\n",top); for(int i=1;i<=top;i++) printf("1/%d = 1/%d + 1/%d\n",n,ans[i].x,ans[i].y原创 2016-02-27 13:25:48 · 187 阅读 · 0 评论 -
UVA 11882(p218)----Biggest Number
#include#include#include#include#includeusing namespace std;typedef long long LL;const int maxn=33;struct node{ int a[maxn],len; void cl() { len=0; } void print原创 2016-02-27 13:49:56 · 265 阅读 · 0 评论 -
UVA 12325(p210)----Zombie's Treasure Chest
#include#include#includeusing namespace std;typedef long long LL;int main(){ //ios::sync_with_stdio(false); //freopen("in.in","r",stdin); //freopen("out.out","w",stdout); LL t,ca原创 2016-02-27 14:03:58 · 349 阅读 · 0 评论 -
UVA 12558(p216)----Eg[y]ptian Fractions(HARD version)
#include#include#include#include#include#define debuusing namespace std;typedef long long LL;const int maxn=10000;set flag;LL a,b,c,k,cas=0;LL ans[maxn];LL v[maxn];LL gcd(LL a,LL b){原创 2016-02-27 14:07:37 · 694 阅读 · 0 评论 -
UVA 129(p195)----Krypton Factor
#include#include#includeusing namespace std;const int maxn=100;int a[maxn];int n,l,cnt;int solve(int dep){ if(cnt++==n) { for(int i=0; i<dep; i++) { if(i%64原创 2016-02-25 22:29:04 · 477 阅读 · 0 评论 -
UVA 140(p196)----Bandwidth
#include#include#include#include#include#include#includeusing namespace std;const int INF=1e7;string st;int num,ansP[10];int p[10],pos[10];vector g[10];char letter[10];void prepare(){原创 2016-02-25 22:30:45 · 399 阅读 · 0 评论 -
UVA 10934(p292)----Dropping water balloons
#include#include#include#include#define debuusing namespace std;typedef unsigned long long ULL;int k;ULL n;ULL f[150][100];void prepare(){ memset(f,0,sizeof(f)); for(int i=1; i<=63;原创 2016-03-26 19:56:22 · 494 阅读 · 0 评论