Math Problem

在这里插入图片描述
题解:
数学推导的问题,暴力明显不行那就猜结论
在这里插入图片描述

#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<set>
#include<map>
#include<iterator>
#include<queue>
#include<vector>
#include<string>
using namespace std;

typedef long long ll;
const int N=1e6+10;
const long long INF=1e18;
const double eps=0.0000001;
int a[N];
char b[100][100];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n=0,m=0,r,ans,one=0,two=0;
    ll x,y,z,t,l;
    scanf("%lld",&t);
    ll s=0,sum;
    while(t--)
    {
       scanf("%lld%lld",&l,&r);
        if((l-1)%192==0)
            n=(l-1)/192;
        else if(((l-1)/192+1)*192+1<=r)
            n=(l-1)/192+1;
        else
            n=(l-1)/192;

        m=(r-1)/192;

        sum=(n+m)*(m-n+1)/2;
        s=m-n+1+sum*192;

        printf("%lld\n",s);

    }
}



猜你喜欢

转载自blog.csdn.net/weixin_43870114/article/details/89817114