UVa简单2017
howlowl
这个作者很懒,什么都没留下…
展开
-
167UVa八皇后——苏丹
之前几道题都做不出来#include#includeint board[8][8];int vis[3][20];int max;void search(int cur,int sum){ if(cur == 8) { if(sum>max) max = sum; return; } for(int i = 0; i < 8;i++) { if(vis[原创 2017-02-17 18:46:21 · 246 阅读 · 0 评论 -
UVa193图染色
#include#includeint m,n,k;int graph[110][110];int node[110]; //0 for white, 1 for blackint maxblack;int ans[110];//try to 'blacken' all nodes from 0 to n-1void dfs(int cur, int black){ if(cu原创 2017-05-15 20:30:15 · 172 阅读 · 0 评论 -
UVa10001伊旬园
就是题目特别难懂#include#includeint left[8] = {0,0,0,0,1,1,1,1};int cell[8] = {0,0,1,1,0,0,1,1};int right[8] = {0,1,0,1,0,1,0,1};int newc[8];int autom;int len;char cnum[50];int target[50];int ans[原创 2017-05-15 17:09:36 · 273 阅读 · 0 评论 -
UVa苏丹的继承者
#include#includeint graph[8][8];int col[8];int tl;int biggest;void dfs(int row){ if(row == 8) { int sum = 0; for(int i=0; i < row; ++i) { sum += graph[i][col[i]]; } if(sum > bigg原创 2017-05-15 03:08:49 · 333 阅读 · 0 评论 -
10085UVA最远的状态
也是和例题几乎一样~#include#includetypedef int State[9];const int maxstate=1000000;const int dx[]={-1,1,0,0};const int dy[]={0,0,1,-1};char dir[]={'U','D','R','L'};State que[maxstate];int fa[maxstate原创 2017-02-23 22:47:54 · 250 阅读 · 0 评论 -
10004UVa二染色
#include#includeint node[200];int gra[200][200];int n,e;bool dfs(int u,int pre){ node[u]=-pre; for(int v = 0; v < n;v++) { if(gra[u][v]) { if(node[v]&& node[v] == node[u]) return原创 2017-02-01 02:44:12 · 271 阅读 · 0 评论 -
532UVa三维迷宫
#include#includeint dl[6]={0,0,0,0,1,-1};int dr[6]={-1,+1,0,0,0,0};int dc[6]={0,0,-1,+1,0,0};const int max = 35;char dung[35][35][35];int dist[35][35][35];int visit[35][35][35];int q[max*max*原创 2017-01-31 04:26:14 · 328 阅读 · 0 评论 -
748UVa迷宫探索
gets()函数好像不同通过编译了?#include#include#includechar maze[50][100];int numr;void dfs(int i,int j);int main(){ // freopen("input.txt","r",stdin); int numcase; scanf("%d",&numcase); getchar();原创 2017-01-30 02:12:00 · 179 阅读 · 0 评论 -
527UVa油井
#include#includechar oil[110][110];bool visited[110][110];int count;void dfs(int i,int j);int main(){ // freopen("input.txt","r",stdin); int m,n; while(scanf("%d%d",&m,&n)==2 && m) { cou原创 2017-01-29 20:40:18 · 280 阅读 · 0 评论 -
10420UVA 读入国家名和女人名
原来根本不用检查女人姓名是否重复。。。#include#include#include#includechar country[2010][25];int str_cmp(const void* _a, const void* _b){const char* a =(const char*) _a;const char* b =(const char*) _b;原创 2017-01-06 18:41:54 · 331 阅读 · 0 评论 -
712UVa简单题S树
#include#includeint varpos[10];int res[1<<7+10];int route[10];int main(){ // freopen("input.txt","r",stdin); int n; int count = 1; char var[5]; while(scanf("%d",&n)==1 && n) { printf("S原创 2017-01-27 03:41:07 · 180 阅读 · 0 评论 -
839UVa简单题天平
#includebool equili;int tree();int main(){ // freopen("input.txt","r",stdin); int numcase; scanf("%d",&numcase); while(numcase--) { equili = true; tree(); if(equili) puts("YES");原创 2017-01-29 18:33:02 · 200 阅读 · 0 评论 -
LRU入门——统计整数正因子个数
#include<stdio.h>#include<string.h>#include<math.h>int main(){ //输入整数n,统计它的正因子个数 long long n; int cnt; while(scanf("%lld", &n) == 1) { cnt = 0; for(int fac = 1; ...原创 2018-08-24 23:25:06 · 542 阅读 · 0 评论