#include<iostream> #include<vector> #include <cmath> using namespace std; int main(){ int t,k; int book[100001]; cin>>t>>k; for(int i=1;i<100001;i++){ if(i<k){ book[i]=1; }else if(i==k){ book[i]=2; }else{ book[i]=book[i-1]+book[i-2]; } } for(int j=0;j<t;j++){ int a,b; int res=0; cin>>a>>b; for(int i=a;i<=b;i++){ res+=book[i]; } cout<<res%1000000007<<endl; } return 0; } //3 2 //1 3 //2 3 //4 4
点赞 评论
牛客网
牛客网在线编程
牛客网题解
牛客企业服务