Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:这种题怎么才这么几个人acIn Reply To:这种题怎么才这么几个人ac Posted by:zhangxiao1124 at 2008-05-01 17:07:25 汗...原来可以这么搜过,我推了半天公式还得用java写个高精 > #include<iostream> > using namespace std; > #define maxn 2005 > int k,n,m,a[maxn],ans[maxn][maxn]; > > void Dfs(int dep,int sum) { > if (dep>n) { > if (a[n] || n==1) { > m++; > for (int i=1; i<=n; i++) ans[m][i]=a[n+1-i]; > } > return; > } > for (a[dep]=0; a[dep]<k; a[dep]++) { > int tot=0; > for (int i=1; i<=dep; i++) { > int j=dep+1-i; > tot+=a[i]*a[j]; > } > if ((tot+sum)%k==a[dep]) Dfs(dep+1,(tot+sum)/k); > } > } > > inline char Change(int x) { > if (x<=9) return '0'+x; > return 'A'+x-10; > } > > void Print() { > printf("%d\n",m); > for (int i=1; i<=m; i++) { > for (int j=1; j<=n; j++) printf("%c",Change(ans[i][j])); > printf("\n"); > } > } > > int main() { > scanf("%d%d",&k,&n); > Dfs(1,0); > Print(); > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator