AtCoder Beginner Contest 206

文章目录

  • AtCoder Beginner Contest 206
    • A - Maxi-Buying
    • B - Savings
    • C - Swappable
    • D - KAIBUNsyo
    • E - Divide Both
    • F - Interval Game 2

AtCoder Beginner Contest 206

A - Maxi-Buying

题意:

题解:

代码:

#include 

#define int long long
#define debug(x) cout << #x << " = " << x << endl;
using namespace std;

inline int read() {
   
   int s = 0, w = 1;
   char ch = getchar();
   while (ch < '0' || ch > '9') {
   if (ch == '-') w = -1; ch = getchar();}
   while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
   return s * w;
}

int const MAXN = 2e5 + 10;
int n, m, T;

signed main() {
   
    cin >> n;
    int tmp = (int)floor((double)n * 1.08);
    if (tmp < 206) cout << "Yay!";
    else if (tmp == 206) cout << "so-so";
    else cout << ":(";
    return 0;
}

B - Savings

题意:

题解:

代码:

#include 

#define int long long
#define debug(x) cout << #x << " = " << x << endl;
using namespace std;

inline int read() {
   
   int s = 0, w = 1;
   char ch = getchar();
   while (ch < '0' || ch > '9') {
   if (ch == '-') w = -1; ch = getchar();}
   while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
   return s * w;
}

int const MAXN = 2e5 + 10;
int n, m, T;

signed main() {
   
    cin >> n;
    for (int i = 1; i <= n; ++i) {
   
        if ((i + 1) * i / 2 >= n) {
   
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

C - Swappable

题意: 给定长度为N的数组A,让你找到有多少对(i, j)使得1 <= i < j <= N, 且 A i ≠ A j A_i \neq A_j Ai=Aj 2 < = N < = 3 ∗ 1 0 5 , 1 < = A i < = 1 0 9 2<=N<=3*10^5, 1<=A_i<=10^9 2<=N<=3105,1<=Ai<=109

题解: 所有的对数就是对于当前的 A i A_i Ai 来说,找到有多少个和 A i A_i Ai 不同的数字。那么就是 ∑ c

你可能感兴趣的:(ACM--比赛补题)