B God Create Math 思维问题

本文深入探讨了数学与计算机科学的融合,通过解析神发送的数学难题,展示了计算机作为人类智慧结晶的体现。文章详细介绍了如何解决特定的数学问题,包括阶乘、自然对数、斐波那契数列等概念的应用,以及如何在给定的限制下计算特定表达式的值。此外,还分享了解题过程中的陷阱和关键点,特别强调了在特定数值范围内的阶乘操作和对数学函数的理解。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


B.God Create Math

 

There is a saying: computer was the crystallizationof men' intelligence, but math is  fromgod. Today, god also sends us a problem.

                sin (n! * [ln(n)] * fib(n) %2012)

Some explanations:

In sin(x), x is a radian.

0! = 1, n! = (n-1)! * n (n >= 1).

[x] is the integer part of a floatingnumber.

fib(0) = fib(1) = 1, and fib(n) = fib(n-1)+ fib(n-2) (n >= 2).

Your task is calculating the value with agiven N.

 

Input

 

The first line contains a single integer T,indicating the number of test cases.

Each test case contains one integer N (1<= N <= 1000 000 000).

 

Output

 

For each test case, output the resultrounded to three fractional digits.

 

Sample Input

 

3

1

4

10

 

Sample Output

 

0.000

0.581

0.978

队内赛出了这道题,就是木有注意到n!到了2012就mod2012余0了这样对于 sin (n! * [ln(n)] * fib(n) %2012)  这个式子来讲,当n超过了2012就mod2012余0了,这样要注意 就是sin(0)为0.000 这里要注意 然后就是计算2012以内的阶乘和fibnaci的值即可 求ln 用log函数。  我直接把fibnaci看成矩阵乘法求大的fabonaci了~~就悲剧了。


#include<stdio.h>
#include<math.h>
#include<string.h>
int a[2100],fib[2100];
void facotoria()    //求阶乘
{
   int i;
   a[0]=1;
   a[1]=1;
   for(i=2;i<=2011;i++)     
     a[i]=(a[i-1]*i)%2012;
}

void f()   //求fibnaci
{
   int i;
   fib[0]=1;
   fib[1]=1;     
   for(i=2;i<=2011;i++)     
      fib[i]=(fib[i-1]%2012+fib[i-2]%2012)%2012;   
}


int main()
{ 
     facotoria();
     f();
     double ans;
     int n,num;
     scanf("%d",&n);
     while(n--)
     {
         scanf("%d",&num);
         if(num>=2012){printf("0.000\n");continue;}  //当大于2011 的时候值为0.000  注意要输出0.000     
         else printf("%.3lf\n", sin (   (double) ( (a[num]*fib[num])%2012*(int)log(num) %2012 ) )  );      
               
     }
    
    


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值