ABC319の自分の解法です。残念ながらAtCoderのコンテストには時間の都合上、参加できないのですが、後で解いたものを少しでも残せたらと思います。
A問題
まずはA問題から。
特に解法を書くまでもないと思う。条件分岐をするだけ。
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
int main() {
string s;
cin >> s;
if (s == "tourist") cout <<"3858"<< endl;
if (s == "ksun48") cout <<"3679"<< endl;
if (s == "Benq") cout <<"3658"<< endl;
if (s == "Um_nik") cout <<"3648"<< endl;
if (s == "apiad") cout <<"3638"<< endl;
if (s == "Stonefeang") cout <<"3630"<< endl;
if (s == "ecnerwala") cout <<"3613"<< endl;
if (s == "mnbvmar") cout <<"3555"<< endl;
if (s == "newbiedmy") cout <<"3516"<< endl;
if (s == "semiexp") cout <<"3481"<< endl;
return 0;
}
ここの条件分岐のところにいつか僕の名前が載ることを願う。というか載って見せる!まずは緑コーダーから脱出しないとなぁ。
B問題
問題を理解するのに時間がかかってしまった。読解力がないことがバレてしまう・・・
まあそれはともかく、全然難しい問題ではない。各$i=0,1,2,…,N$について、各$j=1,2,3…,9$を試せばいい。$N$が$j$で割り切れて、$i$が$n/j$で割り切れるなら、出力すればいい。そして、各$j=1,2,3…,9$の中で、それらを満たすものがなければ、$-$を出力すればいい。
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
int main() {
int n;
cin >> n;
rep(i, n + 1) {
for (int j = 1; j <= 9; j++) {
if(n % j == 0 && i % (n / j) == 0){
cout << j;
break;
}
if (j == 9) cout << '-';
}
}
cout << endl;
return 0;
}
すみません。とりあえずこんな感じです。まだまだ更新予定なので、これからもよろしくお願いいたします。