hdu 3419 The Three Groups(dfs)
来源:互联网 发布:医保大数据分析 编辑:程序博客网 时间:2024/05/22 03:48
对几种情况加了特判就过了。
#include<stdio.h>#include<string.h>#define N 10int vis[N],mark[N][N][N];int a,b,c;int x,y,z;int cnt;void dfs(int t,int f,int k){ if(k==1&&f==a) x=t,f=0,k++,t=0; else if(k==2&&f==b) y=t,f=0,k++,t=0; else if(k==3&&f==c) { z=t; if(x*y==z) cnt++; return ; } for(int i=1;i<=9;i++) { if(vis[i]==0) { vis[i]=1; dfs(t*10+i,f+1,k); vis[i]=0; } } return ;}int main(){ memset(mark,0,sizeof(mark)); while(scanf("%d%d%d",&a,&b,&c),a+b+c) { if(a+b<c) { printf("0\n"); continue; } if(a>c||b>c) { printf("0\n"); continue; } if(a+b-c>1) { printf("0\n"); continue; } if(mark[a][b][c]) { printf("%d\n",mark[a][b][c]); continue; } cnt=0; memset(vis,0,sizeof(vis)); dfs(0,0,1); mark[a][b][c]=cnt; printf("%d\n",mark[a][b][c]); } return 0;}
- hdu 3419 The Three Groups(dfs)
- HDU 3419 The Three Groups(回溯+减枝)
- HDU 5878 I Count Two Three (dfs+二分)
- HDU 5878 I Count Two Three (DFS预处理 + 二分)
- hdu 4751 Divide Groups (两种解法 1.bfs 2.dfs)
- HDU - 4293 Groups (DP)
- HDU 4293 Groups(dp)
- hdu 2616 Kill the monster(DFS)
- hdu 1072 The area(dfs)
- HDU 4462 Scaring the Birds(dfs)
- hdu Tempter of the Bone(DFS)
- hdu 2616 Kill the monster(dfs)
- HDU 4751 Divide Groups (BFS)
- hdu 4293 Groups(动态规划)
- HDU-#4751 Divide Groups(2-SAT)
- HDU - 4751 Divide Groups(二分图)
- HDU 4293 Groups(区间dp)
- GYM 100247 E. Of Groups and Rights(dfs)
- 静态导入
- 网络爬虫本质
- 预编译头文件
- Objective-C语法之代码块(block)的使用
- php 的常用函数
- hdu 3419 The Three Groups(dfs)
- 单位分享交流论坛《好玩的软件》交流总结
- Mysql数据库优化技术
- 设置通过response返回的信息设置客户端的输出编码
- System
- 好的技术博客推荐
- 一个用户如何访问另一个用户的表
- nagios 监控页面脚本
- pydev快捷键汇总