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 |
算法有问题吗?#include<stdio.h> int t=0,a[5842]={1}; void f(int m) { int n; n=m; if(t>5500) return; a[t]=n; t++; if(n<=1000000000)f(2*n); if(n<=666666666)f(3*n); if(n<=400000000)f(5*n); if(n<=285714285)f(7*n); } int main() { int n,x; f(1); for(int i=0;i<5482;i++) { for(int x,j=i+1;j<5482;j++) { if(a[i]<a[j]) { x=a[i]; a[i]=a[j]; a[j]=x; } } } while(scanf("%d",&n)&&n!=0) printf("%d\n",a[n]); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator