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?

競プロ日記#25/04/15

Posted at

AtCoder

AGC014_A-Cookie Exchanges

  • 正直そんなに難しくない
  • A,B,Cのいずれかが既に奇数である場合は交換できない→0を出力というパターンの考慮が漏れていて1パータンだけWA出てしまった。
  • というか過去問くらいはinputとoutputのデータ欲しい...。(実はどこかで見れるとかだったら教えてください...)
  • AGCは解いたことなかったが少し他の回のも見てみるとA問題でも配点が400とか500なので300点問題の当問題はやはり簡単な部類なのだろう...。
  • ただし解説を見ればわかるがこのロジックでも計算量に問題がないということを意識できていなかったので良くないなと思った。

int main() {
    int A,B,C;
    cin >> A >> B >> C;
    vector<int> v(3);
    if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    if (A == B && B == C) {
        cout << -1 << endl;
        return 0;
    }
    v[0] = A;
    v[1] = B;
    v[2] = C;
    int ans = 0;
    while(v[0] % 2 == 0 && v[1] % 2 == 0 && v[2] % 2 == 0) {
        int halfV0 = v[0] / 2;
        int halfV1 = v[1] / 2;   
        int halfV2 = v[2] / 2;
        v[0] = halfV1 + halfV2;
        v[1] = halfV0 + halfV2;
        v[2] = halfV0 + halfV1;
        
        ans++;
    }
    cout << ans << endl;
}

アルゴ式-[パスワードの可能性 (1)

](https://algo-method.com/tasks/736)

  • 結局は積を求めるだけ。
  • パスワードの候補に関してはミスリード
int N,M;
cin >> N >> M;

cout << N * M << endl;

アルゴ式-ラッキーナンバー (1)

  • 3桁のうち各桁を選ぶ選択肢がN通りなのでNの3乗を求める
int main() {
    int N;
    cin >> N;

    cout << N * N * N << endl;
}

アルゴ式-ラッキーナンバー (2)

  • ヒントがあったから「N個のラッキーナンバーのいずれも使っていない3桁の数」の余事象を取ればよいだけだとわかったがこのヒントがなければ解けなかった可能性あり...。
  • 高校レベルの数学の復習が必要か...?

※「環境構築したのをいいことにアルゴ式をサボってAtCoderばっかやりがち」になりそうで怖い...。

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?