hdu-4279//神code ,其实水得很,…

本文探讨了使用C++编程语言解决特定数列问题的方法,包括定义宏简化计算,实现复杂数学函数,以及优化算法以提高效率。通过实例展示了如何利用C++特性解决实际问题。
#include  
#include  
#include  
#include  
#include  
#include 
#include  
#include  
#define ll long long  
#define oo 1000000000  
#define pi acos(-1)  
using namespace std;        
int t,n,s[20]={0,0,0,0,0,0,1,1,2,3,4,4,5};     
ll a,b,p1,p2;  
ll getsum(ll x)  
{  
     if (x<=12) return s[x];  
     ll m,k;  
     m=x/2;   
     k=(ll)sqrt(x);  
     if (k%2==0) m-=2;  
        else m-=1;  
     return m;  
}  
int main()  
{    
    // freopen("input.txt","r",stdin);    freopen("output.txt","w",stdout);   
     scanf("%d",&t);  
     while (t--)  
     {   
            scanf("%I64d%I64d",&a,&b);  
            a--;  
            p1=getsum(a);    
            p2=getsum(b);  
            printf("%I64d\n",p2-p1);  
     }  
     return 0;  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值