はむこの勉強記録

http://bit.ly/2ktf20t の写し

yukicoder April Fool Contest 2017 (シェル芸とか)

#163634 No.3020 サンシャイン◯崎 - yukicoder

YEAH!をくっつけた入力を、1文字1行にして、ソートして隣接カウントして、再度1行に戻して、対応する部分をawkで抽出。

echo $(</dev/stdin)'YEAH!' | sed 's/./&\n/g' | sort | uniq -c | awk '{print $2, $1}' | xargs | awk '{print $11-1, $7-1, $5-1, $9-1, $3-1}'

#163636 No.3022 縛りFizzBuzz (Easy) - yukicoder

C++では大域変数が0で初期化される。あとは気合でインクリメントで数を合わせる。

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

int i;
int three;
int five;
int main(void) {
    int n; cin >> n;
    i++;
    three++; three++; three++;
    five++; five++; five++; five++; five++;
    while (i <= n) {
        if (!(i % three)) {
            cout << "Fizz";
        } 
        if (!(i % five)) {
            cout << "Buzz";
        }

        if (i % three && i % five)
            cout << i;
        cout << endl;
        i++;
    }
    return false;
}

#163637 No.3023 素数判定するだけ - yukicoder

素数判定(1000以下)。埋め込み。

#163640 No.3026 Third Power Problem - yukicoder

a3 mod mが2つ与えられるので、mを推定する。サンプルに992086464があるので、そこからincrementして合うmを探した。いつもの十億七。