matthew as a q.

競技プログラミングメイン

doubleが整数かどうかの判定

doubleが整数になるかの比較方法を知らなかったのでメモ。

方法

以下のラムダ式を用意して使用。

    auto isInteger = [](double x) -> bool {
        return std::floor(x) == x;
    };

問題文

ABC133 B Good Distance

計算した距離が整数になる点の組み合わせを数える。

B - Good Distance

提出

Submission #9361069 - AtCoder Beginner Contest 133

Atcoder Beginner Contest 148

A

やるだけ。

Submission #9243751 - AtCoder Beginner Contest 148

B

std::string組み合わせシミュレーション。

Submission #9244107 - AtCoder Beginner Contest 148

C

LCM.

Submission #9244171 - AtCoder Beginner Contest 148

D

LISを作る。LISの先頭が1でないとき-1、1から始まるときいくつまでincrementできるか数えたうえで全体から引く。

Submission #9245342 - AtCoder Beginner Contest 148

E

0の続く数を数える。2a * 5bのbの数を数える。

Submission #9245721 - AtCoder Beginner Contest 148

Eはdrkenさんの記事を参考にさせていただきました!

AtCoder ABC 148 E - Double Factorial (500 点) - けんちょんの競プロ精進記録

F

まだ

12月後半に学んだ英語フレーズ

12/18

理解度が異なると、物事進めづらいので。。 If the UNDERSTANDING of the people in the meeting are different from each other, we could not proceed effectively.

同じページを見て進めていく、という表現で、同じ認識で進めることを表している。 Be on the same page=to have the same knowledge and understanding of a situation or something

関係ないけどチキン食べたい I also would like to buy large chickens to be used for Christmas dinner.

頼み事

favor=an act of kindness beyond what is due or usual.

同僚から頼まれる

I ask favors FROM my colleagues.

頼まれて受け入れると対応する義務を負う状態になる

owe=have an obligation to pay or repay (something, especially money) in return for something received.

12/29

スケジュール確認の表現 do you have anything scheduled from 4:00 PM

もし大丈夫なら、カバーしてもらえないですか? If it’s not too much trouble, could you cover for me?

(頼みを聞いてくれたときに使う)借りができたね。 I owe you one

12月前半に学んだ英語フレーズ

12/1

紅葉に感動した I was impressed with autumn leaves.

タスクを振られたら、より早めに手をつけるべき。 When you are assigned with some tasks, you should begin them at an earlier time.

期限までに終わらせてもらえますか? Can you finish your tasks on time?

たくさんの紙をシュレッダーにかけないといけないのは知っているけれども、あなたは既に30分もシュレッダーを使ってるよね。 I know that you have to shred a lot of papers, but you have been using machine for 30 minutes now. 私もすぐにこのドキュメントをシュレッダーにかける必要があるの、次の10分でミーティングに参加するために。 I also need to shred this documents immediately, so that I could attend meeting in the next 10 minutes. すぐに終わらせてもらえますか? Could you finished your tasks right away?

12/2

()内の表現の代わりに大文字の表現を使うほうがベター。 I went to (watch) SEE autumn leaves (to) IN the park near my house.

He talked WITH her in private.

I usually (hear) LISTEN to their situation first.

let off some steam: talk a lot to release their feeling of anger

ventilate: express; put into words (They just want to ventilate their feelings.)

12/8

プレゼンテーションにはこちらが適している。 This will suit for your presentation.

うるさい(の間接的な言い方) I'm getting ear pain.

12/9

(しゃべってると冠詞(article)忘れがち) He did not prepare THE agenda.

Not good: She felt anxiety. Better: She felt anxious.

(しゃべっていると途中で必要ないwould like toとかはさみがちなので注意) Could our boss and I would like to talk with you?

副詞 adverb

形容詞 adjective

12/11

The boss will describe the information of the project on our meeting

より詳細な情報を添えるべき Is Thursday, 10am or Friday, 11am good for you? Can we meet either on Wednesday afternoon at 3pm or Thursday afternoon at 4pm?

12/13

It is better to work overseas to get more salary.

高齢化が進んでる The number of the elderly is increasing every year

伝え方大事 The delivery of the message is as important as the message itself

12/16

I talked to him about my current situation and his

calm downは動詞 We should calm down ourselves

仕事が多いのに人員が足らない We are under staff.

イデアを勧めるときは、increase, decreaseする、くらいではなく、より具体的な効果を述べるべき。 またアイデア自体も具体的なアイデアを述べるべき。 We should hire 3 additional employees within this month. This will result in the reduction of 20%-30% of our tasks.

12/17

いまさらの自己紹介フレーズ I have been working in our company for about 5 years now.

賛同しかねるときのフレーズ I see what you mean but with lower corporate taxes, the government can't provide enough public services.

英語耳[改訂・新CD版] 発音ができるとリスニングができる

英語耳[改訂・新CD版] 発音ができるとリスニングができる

LAN内端末のIPを調べる

環境

リモートデスクトップ

接続するにはLAN内のプライベートIPアドレスが必要。

そこでLAN内(192.168.1.0/24)のIPアドレスすべてにpingを飛ばし、返答が返ってきた端末のIPアドレス一覧を表示する。 具体的には以下のコマンドを実行する。

echo 192.168.10.{1..254} | xargs -P256 -n1 ping -s1 -c1 -W1 | grep ttl

以下のようなイメージ。

f:id:takeknock:20191126232347p:plain

参考

LAN内で使われているIPアドレスを調べる6つの方法(Linux/Windows) | 俺的備忘録 〜なんかいろいろ〜

根から辿る全探索

木上の累積和で、根から足しこむところで詰まっていたので、そこ含めてメモとして記録。

memo

void dfs(int thisNode, int parent, vector<vector<int>>& graph, vector<int>& c) {
    for (auto nextNode : graph[thisNode]) {
        if (nextNode == parent) {
            continue;
        }
        c[nextNode] += c[thisNode];
        dfs(nextNode, thisNode, graph, c);
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, q;
    cin >> n >> q;
    vector<vector<int>> graph(n, vector<int>());

    for (size_t i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--; b--; // 0 indexed
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
    }

    vector<int> c(n, 0);
    for (size_t i = 0; i < q; i++)
    {
        int p, x;
        cin >> p >> x;
        p--; // 0 indexed

        c[p] += x;
    }

    // 根から足しこむ
    dfs(0, -1, graph, c);

    for (auto result : c) {
        cout << result << " ";
    }
    return 0;
}

bit全探索

memo

for (size_t bit = 0; bit < (1 << (s.size() - 1)); bit++)
    {
        for (size_t i = 0; i < s.size() - 1; i++)
        {
            if (bit & (1 << i)) {
                // bitが立っているとき
                // 数字の区切りでaccumulate等
            }
            else {
                // bitが立っていない場合
                // 位を挙げて今回の計算値を更新する等
            }
        }

Submission #7425849 - AtCoder Regular Contest 061 | AtCoder

参考

AtCoder 版!蟻本 (初級編) - Qiita

bit全探索について簡単にまとめる - Qiita

たくさんの数式 / Many Formulas [ARC 061, ABC 045 C] - はまやんはまやんはまやん

プログラミングコンテストチャレンジブック [第2版] ?問題解決のアルゴリズム活用力とコーディングテクニックを鍛える?

プログラミングコンテストチャレンジブック [第2版] ?問題解決のアルゴリズム活用力とコーディングテクニックを鍛える?