33,010
社区成员
发帖
与我相关
我的任务
分享
值 范围 对应斐波那契的项
0 x<0
1 [0,3.14) 2
2 [3.14,4.14) 3
3 [4.14,6.28) 4
5 [6.28,7.28) 5
.....
值 范围 对应斐波那契的项
0 x<0
1 [0,3.14) 2
2 [3.14,4.14) 3
3 [4.14,6.28) 4
5 [6.28,7.28) 5
.....
int check1(double val){
if(val < 0)
return 0;
if(val < 3.14)
return 1;
if(val > 10000000)
return 0;//无效数据
val *= 100;
int x = (int) val;
if(val > x)//这个值得商榷,实际上整个3.14值得商榷.居然使用double这种非精确数据进行测试.
++ x;
vector<int> v;
v.resize(314,1);
v.resize(x + 1);
for(int i = 314;i <= x;++ i){
v[i] = (v[i - 100] + v[i - 314]) % 1000000007;
//Test ++;
}
return v[x];
}
int _tmain(int argc, _TCHAR* argv[])
{
double x ;
x = 1000;
time_t t = clock();
Test = 0;
t = clock();
cout<<check1(x)<<endl;
t = clock() - t;
cout<<t<<endl;
//cout<<Test<<endl;
return 0;
}
using System;
using System.Collections.Generic;
namespace CSharpTest
{
class Program
{
static Dictionary<double, int> dict = new Dictionary<double, int>();
public static void Main()
{
Console.WriteLine(F(1000));
}
static int F(double n)
{
if (n < 0)
return 0;
if (n < 1)
return 1;
if (!dict.ContainsKey(n))
{
int result = (F(n - 1) + F(n - 3.14)) % 1000000007;
dict.Add(n, result);
}
return dict[n];
}
}
}
typedef unsigned int UINT;
double C(double n, double m)
{
double ret = 0;
if (m > n/2)
m = n-m;
for (double i = m+1; i <= n; ++i)
ret += log(i);
for (double i = 2; i <= n-m; ++i)
ret -= log(i);
return exp(ret);
}
double getSibonacci(double x)
{
if (x < 0)
return 0;
else
{
double ret = 1;
for (double i = 1; ; ++i)
{
int temp = x - 3.14*i;
if (temp > 0)
ret += C((double)(temp+i), (double)temp);
else
break;
}
return ret;
}
}
#include<iostream>
using namespace std;
int main(){
int m[100001];
for(int i=0;i<100001;i++){
if(i<314)m[i]=1;
else m[i]=(m[i-100]+m[i-314])%1000000007;
}
int n;
cin>>n;
while(n-->0){
double a;
cin>>a;
if(a<0)cout<<0<<endl;
else{
int b = (int)(a*100+0.000001);
cout<<m[b]<<endl;
}
}
}