AtCoder Beginner Contest 148

はい. AtCoder Beginner Contest 148 です
本当は ABC146,147 を先に書かないといけないんですけど,このままだと永遠にスタックされていきそうなので,とりあえず ABC148 について書きます.

ABCDの4完でした.結構簡単だったみたいで,パフォーマンス低かったです…
E が解けませんでした.解きたかった_(:3」∠)_
F も時間があってちゃんと考察したら解けそうな気がしています(気がしているだけ)


A - Round One

問題文

選択肢が  1,2,3 であり,選択肢  A,B が誤答だと分かっているようです.
合計が 6 であることが分かっているので,  6 - A - B を出力すれば良いです.

#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

typedef long long int64;


int main() {
    int a,b;
    cin >> a >> b;
    cout << 6 - a - b << endl;
}



B - Strings with the Same Length

問題文

長さが同じなので,交互に出力するだけです.

#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

typedef long long int64;


int main() {
    int n;
    string s,t;
    cin >> n >> s >> t;

    for (int i=0; i<n; i++) cout << s[i] << t[i];
    cout << endl;
}



C - Snack

問題文

 A,B で割り切れる最小の数を出力すれば良いので,最小公倍数を求めます.
最小公倍数(LCM)は, \frac{A \times B}{GCD(最大公約数)} ですね.

#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

typedef long long int64;

int64 gcd(int64 a,int64 b){return b?gcd(b,a%b):a;}

int main() {
    int64 a,b;
    cin >> a >> b;
    int64 GCD = gcd(a,b);
    int64 ans = a*b/GCD;
    cout << ans << endl;
}



D - Brick Break

問題文

順番に 1,2,3,\cdots とならないといけないので,
 1が来るまでレンガを割り続ける, 2 が来るまで… とやっていけば良いです.

そして,1回も1 が出てこなければそういう列が作れません.

#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

typedef long long int64;


int main() {
    int64 n;
    cin >> n;
    vector<int64> a(n);
    for (int i=0; i<n; i++) cin >> a[i];

    int64 ans = 0;
    bool flag = false;
    int64 i = 1;
    for (int j=0; j<n; j++) {
        if (a[j] != i) ans++;
        else i++,flag=true;
    }

    cout << (flag? ans : -1) << endl;
}



E - Double Factorial /

問題文

考察不足でした.10が何個あるか数えてたんですけど,
2 は大量にあるため, 5 が何個あるか(入るか)数えるだけで良かったです.
10以下であることを避けるために最初だけ10で割ります)

#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

typedef long long int64;

int main() {
    int64 n;
    int64 ans = 0;
    cin >> n;
    if (n%2) {
        cout << 0 << endl;
        return 0;
    }

    ans += n /= 10;
    while(n != 0) {
        ans += n /= 5;
    }

    cout << ans << endl;
    return 0;
}

まとめ

またレート下がりました_(:3」∠)_
E問題は「 1331! の下桁に0はいくつ連続するか」という問題と本質的に同じ問題みたいです(↓参考).

中学受験とか高校受験にこんな問題出るんですか(無知).
こういう知識ないので,辛い_(:3」∠)_



参考