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:你的这5点有证明吗?第三点是为什么呀?In Reply To:你的这5点有证明吗?第三点是为什么呀? Posted by:knuthocean at 2005-03-27 11:38:06 有点复杂,我自己写了前几个,发现一点规律。 5 2 3 6 2 4 7 3 4 8 3 5 9 2 3 4 10 2 3 5 11 2 4 5 12 3 4 5 13 3 4 6 14 2 3 4 5 规律自己发现,只好意会,不可言传。代码如下: #include <iostream> using namespace std; int main() { int n,i,s,num,j; scanf("%d",&n); s=0;i=1; while(n>s) { i++; s+=i; } if(n==s) { for(j=2;j<=i;j++) printf("%d ",j); printf("\n"); } else{ s=s-i; i--; num=n-s; for(j=2;j<=i;j++) { if(i-j+1<=num%(i-1)) printf("%d ",j+num/(i-1)+1); else printf("%d ",j+num/(i-1)); } printf("\n"); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator