1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

第六回オフラインリアルタイム参考問題をC++で解いた

Last updated at Posted at 2012-12-29

初めて投稿します。よろしくお願いします。

ゴルフしたかったわけではありませんが、最初は普通に解いたものをコンパクトにしているうちにこのような形になりました。関数作ったあたりがあまりゴルフっぽくなさそうです。

C++で面白い回答をしている方がいれば是非参考にしたいので教えてください。

問題:http://nabetani.sakura.ne.jp/hena/ord6lintersection/
解答例:http://qiita.com/Nabetani/items/4c60f10b73812e86441c

#include <iostream>

bool a(int a, int b, int c) {
  return a <= b & b <= c | c <= b & b <= a;
}

int main() {
  char s[99];
  std::cin >> s;
  int c = 0;
  for (int x = 48; x < 58; ++x)
    for (int y = 48; y < 58; ++y)
      c += a(s[0], x, s[3]) & a(s[1], y, s[4]) | a(s[0], x, s[6]) & a(s[1], y, s[7])
          && a(s[9], x, s[12]) & a(s[10], y, s[13]) | a(s[9], x, s[15]) & a(s[10], y, s[16]);
  std::cout << c;
}
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?