567囧


私信TA

用户名:dotcpp0673056

访问量:629

签 名:

等  级
排  名 57442
经  验 207
参赛次数 0
文章发表 1
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

TA的其他文章

解题思路:
找到规律,不能被平分差的数的是 (x-2)%4 == 0, 然后判断 L,R中有多少个这样的数
注意事项:

参考代码:

#include<bits/stdc++.h>

#define ikun cout<<"kun kun kun"<<endl;

#define INF 999

#define endl '\n'

#define int long long

#define no  {cout<<"NO"<<endl; return;}

#define yes  {cout<<"YES"<<endl; return;}

#define sz size()

#define pb push_back

using namespace std;

const int N = 1005;

const int M = 5e3 + 5;

void solve()

{

    int l,r;

    cin>>l>>r;

    int ans = (r-l+1)-(r-l+1)/4;

    int a = ((l-2)%4+3)%4;

    int b = (r-2)%4;

    if(a>b) ans--;

    cout<<ans;

}

signed main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    int t=1;

    //cin>>t;

    while(t--)

    {

        solve();

    }

}


 

0.0分

4 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区

6
2023-11-02 15:13:18
  • «
  • 1
  • »