1
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?

More than 1 year has passed since last update.

AtCoder ABC406 振り返り #C++

1
Last updated at Posted at 2025-05-24

はじめに

AtCoder ABC406に参加したので振り返ります。
結果は1冠でした(コンテスト成績証)。

A - Not Acceptable

簡単な比較の問題でした。

#include <bits/stdc++.h>
using namespace std;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    if (A > C) {
        cout << "Yes" << endl;
        return 0;
    } else if (A == C) {
        if (B > D) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

B - Product Calculator

ACできませんでした。
友人曰く、オーバーフローしていたとのことです。
128bit整数型を使ったところうまく行ったらしいので、後で直してみます。
なお、Pythonだとデフォルトで多倍長整数だから問題なかったとのことです。

// WAのコード例
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    int A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    int count = 1;
    int compare = 1;
    for (int i = 0; i < K; i++) {
        compare *= 10;
    }

    for (int i = 0; i < N; i++) {
        count *= A[i];
        if (count >= compare) {
            count = 1;
        }
    }
    cout << count << endl;
}

おわりに

long型の精進頑張ります。

1
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
1
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?