hdu1716
来源:互联网 发布:外国域名注册网站 编辑:程序博客网 时间:2024/04/28 23:01
坑爹的格式。。
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;int a[4],hash1[4],vis[4],hash2[10000];int flag,temp,cnt;void Show(){ int num = hash1[0] * 1000 + hash1[1] * 100 + hash1[2] * 10 + hash1[3]; if(hash2[num]) return; else{ hash2[num] = 1; if(temp != hash1[0]){ cnt = 0; temp = hash1[0]; flag++; if(flag) printf("\n"); } if(cnt != 0) printf(" "); for(int i = 0;i < 4;i++){ printf("%d",hash1[i]); } cnt++; } return ;}void Dfs(int x){ if(x == 4){ Show(); return ; } for(int i = 0;i < 4;i++){ if(x == 0 && a[i] == 0)continue; if(!vis[i]){ hash1[x] = a[i]; vis[i] = 1; Dfs(x + 1); vis[i] = 0; } }}int main(){ int k = 0; while(~scanf("%d%d%d%d",&a[0],&a[1],&a[2],&a[3])){ if(!a[0] && !a[1] && !a[2] && !a[3]) break; if(k)printf("\n"); sort(a,a+4); memset(hash1,0,sizeof(hash1)); memset(hash2,0,sizeof(hash2)); memset(vis,0,sizeof(vis)); temp = -1,flag = -1,cnt = 0; Dfs(0); printf("\n"); k++; } return 0;}
0 0
- hdu1716
- hdu1716
- HDU1716
- hdu1716排列2
- hdu1716(排序2 )
- HDU1716-全排列
- hdu1716(库函数next_permutation)
- 华中科技大HDU1716 排列
- hdu1716(排列2)
- 水题:HDU1716-排列2
- HDU1716 全排列
- hdu1716排序(挺不错)
- HDU1716 -- 全排列 -- STL -- next_permutation()
- Get Many Persimmon Trees(hdu1716,枚举)
- hdu1716 STL next_permutation函数的使用
- hdu1716 排列2(排列生成算法)
- HDU1716 排列2 next_permutation的用法
- HDU1716 next_permutation 的简单应用 排列2
- 周一的感觉就像失恋一样 周二的感觉就像找不到对象一样
- android中正确导入第三方jar包
- JQuery插件第四十一:表单输入框获取指定小数位并且四舍五入
- 判断日期是今天,昨天还是明天
- 总有一段时间我们会期待被放逐放逐到无尽的开阔
- hdu1716
- 乘积的末三位
- blog
- include注意点
- 算法竞赛入门经典第3章【小结与习题】
- 将秒数转换成NSDate,加上时区偏移
- 1007. 素数对猜想 (20)
- HttpRuntime.Cache缓存数据
- jsp乱码解决大全