| ||||||||||
| 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:怎么缩短运行时间?In Reply To:怎么缩短运行时间? Posted by:dexter at 2003-08-27 22:08:25 > 此题很简单嘛,只是提交时老是说time limit exceed
> #include<stdio.h>
> #include<malloc.h>
> main()
> {
> int t,i;
> long *a,j;
> scanf("%d",&t);//数据的组数
> a=(long *)malloc(sizeof(long)*t);
> for(i=0;i<t;i++)
> {
> scanf("%ld",a+i);
> }
> for(i=0;i<t;i++)
> {
> for(j=1;;j++)
> {
> if((j*(j+1)/2)>=*(a+i))
> break;
> }
> printf("%ld\n",*(a+i)-j*(j-1)/2);
> }
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator