A题,为什么会错???

#include <bits/stdc++.h>

using namespace std;

#define int long long

#define endl '\n'

#define ios ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

typedef pair<int, int> PII;

const double PI = acos(-1.0);

const int N=2e6+10;

int a,b,c;

int n;

void solve()

{

cin>>a>>b>>c;

cin>>n;

int cnt=0;

for (int i=1;i<=n;i++)

{

int x;

cin>>x;

if ((x>b&&x<=a)||(x>=a&&x<c)) cnt++;

}

cout<<cnt;

}

signed main()

{

ios;

int T = 1;

//cin>>T;

while (T--) solve();

return 0;

}

全部评论
评测数据不满足 b<a<c 捏,你直接判 b<x<c 就过了
点赞
送花
回复
分享
发布于 03-10 18:17 江西
#include<iostream> using namespace std; int a, b, c, n; int temp;  int main() {     cin >> a >> b >> c >> n;     int count = 0;          for (int i = 1; i <= n; i++) {         cin >> temp;         if (temp > b && temp < c)         count++;     }          cout << count;     return 0; } 哥们你写的太多了吧,因为这个题限制b < a < c 所以 我们只要看宝物在 (b, c) 之间就让 count++好了
点赞
送花
回复
分享
发布于 03-11 12:43 上海
滴滴
校招火热招聘中
官网直投

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务