摘要: 好题啊。。。乍一看是复杂的排列组合问题,其实是:每个盘子都可以放到三个柱子上的任意一个,所以是3^n.经典!!代码如下:#include"stdio.h"int main( ){ __int64 num[31]={1}; int i,t,n; for(i=1;i<=30;i++) num[i]=num[i-1]*3; scanf("%d",&t); while(t--) { scanf("%d",&n); printf("%I64d\n",num[n]); } return 0;} 阅读全文
posted @ 2012-05-14 04:43 朝圣の路 阅读(369) 评论(0) 推荐(1) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1259无语了。。这题刚开始wa了一次,当时把每次变动之后J的位置都默认为2了,太2了。代码如下:#include"stdio.h"int main( ){ int t,m,x,y,p; scanf("%d",&t); while(t--) { scanf("%d",&m); p=2; while(m--) { scanf("%d%d",&x,&y); if(x==p)//刚开始把p写成2... 阅读全文
posted @ 2012-05-14 04:08 朝圣の路 阅读(217) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1982这题真是够纠结的啊,开始是pe但找不出神马原因,后来看了别人的代码,发现我没考虑"-----######---##-#-#"这种情况,导致我的pe,应该输出10个空格才对。代码如下:#include"stdio.h"char word[28]={"0ABCDEFGHIJKLMNOPQRSTUVWXYZ"};char a[10005];void output(){ int i,s=0,state=0; for(i=0;a[i]!='\0& 阅读全文
posted @ 2012-05-14 03:36 朝圣の路 阅读(365) 评论(0) 推荐(0) 编辑