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:实在受不了了?试了N个数,但不知道错在哪里。。谁能给个特殊数据??In Reply To:实在受不了了?试了N个数,但不知道错在哪里。。谁能给个特殊数据?? Posted by:wrp at 2009-11-22 19:44:53 > #include<iostream> > #include<math.h> > using namespace std; > int main() > { > int n; > cin>>n; > int arr[31]; > int a,b,c; > int i; > double k; > k=sqrt(double(n)); > a=k; > b=n/a; > c=n%a; > for(i=0;i<a;i++) > arr[i]=b-a/2+i; > if(a%2==0) > { > for(i=a/2;i<a;i++) > arr[i]++; > i=a/2; > while(c>0&&i>0) > { > arr[--i]++; > c--; > } > while(c>0) > {i=a-1; > arr[i--]++; > c--; > } > } > else > { > i=a-1; > while(c>0) > {arr[i--]++; > c--; > } > } > for(i=0;i<a;i++) > cout<<arr[i]<<" "; > cout<<endl; > return 0; > } > > Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator