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:数列求和的纯数学方法,0msACIn Reply To:数列求和的纯数学方法,0msAC Posted by:anjiaqi1234567 at 2012-07-22 11:32:33 > #include <stdio.h> > #include <math.h> > int main() > { > float t; > int n,m; > while(scanf("%f",&t)!=EOF) > { > m=0.5+sqrt(0.25-4*0.5*(1-t));//将图旋转45读度,二元一次方程,求出该数所在第几行,利用整型可以舍去float的小数点的特点 > n=1+m*(m-1)/2;//求出该行有多少个数字,写出来就是个数列求和公式 > if(m%2!=0)//判断行数的奇偶,然后按顺序输出就行了 > printf("TERM %.0f IS %.0f/%.0f\n",t,m-(t-n),t-n+1); > else > printf("TERM %.0f IS %.0f/%.0f\n",t,t-n+1,m-(t-n)); > > } > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator