Official
B - Leyland Number Editorial
by
B - Leyland Number Editorial
by
cn449
初心者の方へ
- プログラミングの学習を始めたばかりで何から手をつけるべきかわからない方は、まずは practice contest の問題A「Welcome to AtCoder」をお試しください。言語ごとに解答例が掲載されています。
- また、プログラミングコンテストの問題に慣れていない方は、 AtCoder Beginners Selection の問題をいくつか試すことをおすすめします。
- C++入門 AtCoder Programming Guide for beginners (APG4b) は、競技プログラミングのための C++ 入門用コンテンツです。
\(A^B\) と \(B^A\) の値をそれぞれ求め、足し合わせればよいです。
\(A^B\) の値は for 文を用いて \(1\) に \(A\) をかける操作を \(B\) 回行うなどの方法で求めることができます。\(B^A\) についても同様です。
実装例
#include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
int x = 1, y = 1;
for (int _ = 0; _ < b; _++) x *= a;
for (int _ = 0; _ < a; _++) y *= b;
cout << x + y << '\n';
}
posted:
last update: