寝癖頭の解法

学習中の覚え書きを投稿、更新していきます。

AtCoder Problems in C, C++ #B - Bishop

パナソニックプログラミングコンテスト2020から、その提出コードの解答例です。
AtCoderとは、コンテストを通じて、プログラミングやアルゴリズムを学習するサービスです。
atcoder.jp
プログラミングコンテストとは、「与えられた問題をいかに素早く、正確に」解くことができるかを競うものです。
競技プログラミング」を略して、「競プロ」などと呼ばれています。

#B - Bishop
atcoder.jp

僕が作成、提出したコードは、以下のとおりです。

/*
AtCoder Problems in C
#B - Bishop
https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_b
提出コードの解答例
https://neguse-atama.hatenablog.com
*/
#include<stdio.h>
int main(void){
  long long int h,w;
  scanf("%lld %lld",&h,&w);
  if(h==1 || w==1){
    printf("1\n");
  }else{
    printf("%lld\n",(h*w+1)/2);
  }
  return 0;
}
/*
AtCoder Problems in C++
#B - Bishop
https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_b
提出コードの解答例
https://neguse-atama.hatenablog.com
*/
#include<stdio.h>
int main(void){
  long long int h,w;
  scanf("%lld %lld",&h,&w);
  if(h==1 || w==1){
    printf("1\n");
  }else{
    printf("%lld\n",(h*w+1)/2);
  }
  return 0;
}

AtCoderの過去問やその他のAtCoderの問題(今回のパナソニックプログラミングコンテスト2020など) は、オンラインジャッジによるプログラミングコンテストです。
https://practice.contest.atcoder.jp/tutorial
アカウントを登録すれば、誰でも参加できます。