1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
#include <iostream> using namespace std; #define M 301 int F[M]; int main() { unsigned long long n,m,s; int t,a,b; int a1,b1; int sum=0; F[1]=1; F[2]=1; F[3]=2; for(int i=4;i<M;i++) { F[i]=(F[i-1]+F[i-2])%100; } //cout<<F[296]<<" "<<F[297]<<" "<<F[298]<<" "<<F[299]<<" "<<F[300]<<" "<<F[301]<<" "<<F[302]<<"\n"; for(int i=1;i<M;i++) { sum+=F[i]; } //cout<<sum<<"\n"; cin>>t; while(t--) { cin>>n>>m; a=n%300; //a1=n/300; b=m%300 ; //b1=m/300; s=0; unsigned long long j,p; for(unsigned long long i=n;i<=m;i++) { if(i%300==0) { s+=F[300]; j=i; break; } s+=F[i%300]; if(i==m) j=m; } if(j==m) { cout<<s<<"\n"; continue; } p=m-j; s+=((p/300)*sum); j=j+(p/300)*300; for(unsigned long long i=j+1;i<=m;i++) { if(i%300==0) { s+=F[300]; j=i; break; } s+=F[i%300]; } cout<<s<<"\n"; } return 0; } |