AtCoder Beginner Contest 199(Sponsored by Panasonic)

简介: A - Square Inequality

A - Square Inequality


题意:

If A^2+ B^2 < C^2 holds, print Yes; otherwise, print No.


int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if (a * a + b * b < c * c) {
    scYes;
  }
  else
    scNo;
}


B - Intersection


题意:给你t个区间【Ai,Bi】,并且规定了Ai<x<Bi,求最后x可以取几个值。


int main()
{
  int t, i, j, n;
  int min1 = 0x3f3f3f3f, max1 = 0;
  cin >> t;
  for (i = 0; i < 2*t; i++) {
    int d; cin >> d;
    if (i < t) {
      max1 = max(max1, d);
    }
    else {
      min1 = min(min1, d);
    }
  }
  cout << max((min1 - max1)+1, 0) << endl;
}在这里插入代码片


C - IPFL


题意:给你个一个字符串,有q次操作,操作1是交换输入的两个下对应的字符串里的字母,操作2是反转前半部分字符串和后半部分字符串。


思路:操作次数很大,模拟会t,找规律,模拟的想把一个字符串分为两半,这样交换的操作也可以分解,反转的操作也可以分解。


int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  int i,n, q, d1, d2, d3;
  string s1,ans1,ans2;
  cin >> n >> s1 >> q;
  int dd = s1.length();
  for (i = 0; i < s1.length(); i++) {
    if (i < s1.length() / 2)
      ans1 += s1[i];
    else
      ans2 += s1[i];
  }
  int flag = 0;
  for (i = 0; i < q; i++) {
    cin >> d1 >> d2 >> d3;
    if (d1 == 1) {
      if (d2 <= n) {
                if (d3 > n) {
          if (flag == 0) {
            d3 -= 1, d2 -= 1;
            swap(ans1[d2], ans2[d3 - n]);
          }
          else {
            d3 -= 1, d2 -= 1;
            swap(ans2[d2], ans1[d3 - n]);
          }
        }
else {
            d2 -= 1, d3 -= 1;
            if (flag == 0)swap(ans1[d2], ans1[d3]);
            else swap(ans2[d2], ans2[d3]);
        }
      }
      else {
           d3 -= 1, d2 -= 1;
           if (flag == 0)swap(ans2[d2 - n], ans2[d3 - n]);
           else swap(ans1[d2 - n], ans1[d3 - n]);
      }
    }
    else if (d1 == 2) {
      if (flag == 0){
                 flag = 1;
      }
      else flag = 0;
    }
  }
  if (flag == 0) {
    cout << ans1 << ans2 << endl;
  }
  else {
    cout << ans2 << ans1 << endl;
  }
}
相关文章
|
人工智能
atcoder AtCoder Beginner Contest 210 D - National Railway(dp)
atcoder AtCoder Beginner Contest 210 D - National Railway(dp)
116 0
|
机器学习/深度学习 人工智能 Java
AtCoder Beginner Contest 215 D - Coprime 2 (质因子分解 gcd)
AtCoder Beginner Contest 215 D - Coprime 2 (质因子分解 gcd)
110 0
|
算法
AtCoder Beginner Contest 213 E - Stronger Takahashi(01BFS)
AtCoder Beginner Contest 213 E - Stronger Takahashi(01BFS)
137 0
AtCoder Beginner Contest 133 E - Virus Tree 2(组合数学)
AtCoder Beginner Contest 133 E - Virus Tree 2(组合数学)
107 0
|
机器学习/深度学习
AtCoder Beginner Contest 218 C - Shapes (模拟)
AtCoder Beginner Contest 218 C - Shapes (模拟)
149 0
|
机器学习/深度学习
AtCoder Beginner Contest 215 E - Chain Contestant (状压dp)
AtCoder Beginner Contest 215 E - Chain Contestant (状压dp)
124 0
AtCoder Beginner Contest 174 ——D.Alter Altar(思维)
AtCoder Beginner Contest 174 ——D.Alter Altar(思维)
90 0