HUST 1003 Sibonacci Numbers(杂题)

题目链接:http://acm.hust.edu.cn/problem.php?id=1003

As is known to all, the definition of Fibonacci Numbers is:
f(1)=1
f(2)=1
f(n)=f(n-1)+f(n-2) (n>=3)

Now Sempr found another Numbers, he named it "Sibonacci Numbers", the definition is below:
f(x)=0 (x<0)
f(x)=1 (0<=x<1)
f(x)=f(x-1)+f(x-3.14) (x>=1)

求f(n)

结果对1000000007取余数

这个转换成整数,然后注意精度,貌似不需要用long long

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#define eps 1e-8
using namespace std;
const int maxn = 100010;
const int mod = 1000000007;
int rec[maxn];
int init(){
    int i,j,k;
    for(i=0;i<314;i++)
    rec[i]=1;
    for(i=314;i<maxn;i++)
    rec[i]=(rec[i-100]+rec[i-314])%mod;
    return 0;
}
int main(){
    int i,j,k,ans,t;
    double w;
    init();
    scanf("%d",&t);
    while(t--){
        scanf("%lf",&w);
        if(w<0){
            printf("0\n");
            continue;
        }
        ans=int((w+eps)*100);
        printf("%d\n",rec[ans]);
    }
    return 0;
}


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值