0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AtCoder Beginner Contest 400(ABC400)振り返り(初参加)

Posted at

はじめに

AtCoder Beginner Contest(ABC)初参加ということで、ABC400に参戦しました。
慣れない(本来この時間は既に寝ている)環境の中、今回は2問解きました。

今回はC++で挑戦しました。

概要

  • AtCoder Beginner Contest 400に参加した
  • 数学教養不足
  • A問題はボーナス問題
  • B問題は法則性を見つけ出してどうにかAC(正解)
  • C問題以降、今の私には無理
  • 圧倒的数学教養不足

A - ABC400 Party

ABC400回記念問題が多かったのですが、これもそのうちの一つです。
読み解くのに若干時間がかかりましたが、これは明らかにボーナス問題でした。ありがたい。

ABC400 A 提出コード
A.cpp
// A - ABC400 Party
#include <bits/stdc++.h>
using namespace std;

int main() {
  int A;
  cin >> A;

  if (400 % A <= 0) {
    cout << 400 / A << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}

何故==じゃなくて<=なのかは聞かないでください。眠かったんです。多分。

B - Sum of Geometric Series

今回は400回記念であると同時に、数学祭りでもありました。
自分の数学素養の無さが露呈してしまい、再履修が必要かな、と思いました。

入力例1から法則性を導き出して、どうにかAC獲得。
pow関数の返し値がdoubleということで、doubleを使って行うようにしました。
表示がe表記になってしまったので、std::fixedとstd::setprecision(0)を使っています。

ABC400 B 提出コード
B.cpp
// B - Sum of Geometric Series
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;

  double sum = 1;
  for (int i = 1; i <= M; i++) {
    sum += pow(N, i);
  }
  if (sum > 1000000000) {
    cout << "inf" << endl;
  } else {
    cout << fixed << setprecision(0);
    cout << sum << endl;
  }
  return 0;
}

C問題から先

ここから先、問題文だけは見ましたが、今の私にはちょっと理解不能です。
数学祭りだとやはり厳しいですね。

まとめ

今回のコンテストで数学素養が足りないのを痛感したので、まずは数学の勉強から始めようと思いました。
あと、ABCやDaily Trainingには引き続き出来うる限り参加します。場数を踏むのも大切ですから。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?