AT_gigacode_2019_b 採用面接 の 题解

发布时间 2023-12-21 10:55:53作者: NFGase

这道题比较水。大概思路是使用循环,之后检查 \(a_{i}\) 是否达到 \(x\)\(b_{i}\) 是否达到 \(y\)\(a_{i} + b_{i}\) 是否达到 \(z\)

代码如下。

#include <iostream>
namespace io{
    template <typename T> inline void read(T& x){x = 0; bool f = false; char ch = getchar(); while(ch < '0' || ch > '9'){if(ch == '-') f = !f; ch = getchar();}while(ch >= '0' && ch <= '9'){x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();} x = (f ? -x : x); return;}
    template <typename T, typename... Args> inline void read(T& x, Args&...x_){read(x), read(x_...);}
    template <typename T> inline void put(T x){if(x < 0) putchar('-'), x = -x; if(x > 9) put(x / 10); putchar(x % 10 + '0'); return ;}
    template <typename T> inline void write(T x){put(x);}
    template <typename T, typename... Args> inline void write(T x, Args...x_){write(x), write(x_...);}
    inline void newb(){putchar(' ');}
}
namespace code{
    int n, x, y, z, a[101], b[101], cnt = 0;
    int main(){
        io::read(n, x, y, z);
        for(int i = 1; i <= n; i++) io::read(a[i], b[i]);
        for(int i = 1; i <= n; i++) if(a[i] >= x && b[i] >= y && a[i] + b[i] >= z) cnt++;
        io::write(cnt);
        return 0;
    }
}
int main(){
    code::main();
    return 0;
}

记录