0
0

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 3 years have passed since last update.

パナソニックプログラミングコンテスト2020 A~C

Last updated at Posted at 2020-03-15

パナソニックプログラミングコンテスト2020
https://atcoder.jp/contests/panasonic2020/tasks

#A問題
image.png

A問題.c++
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int A[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K; cin >> K;
    cout << A[K-1] << endl;
    return 0;
}

#B問題
image.png

B問題.c++
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll H,W; cin >> H >> W;
    if (H==1 || W==1) cout << 1 << endl;
    else if (H%2!=0 && W%2!=0) cout << H*W/2+1 << endl;
    else cout << H*W/2 << endl;
    return 0;
}

#C問題
image.png

C問題.c++
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll a,b,c; cin >> a >> b >> c;
    ll tmp=c-(a+b);
    if (tmp>0 && 4*a*b<tmp*tmp) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

#まとめ
・B問題 if (H==1 || W==1) cout << 1 << endl;を考慮出来てなかった…
・C問題 sqrt使うにはdouble型にしなければいけないが、double型でやると誤差
が生じるため、なんとかll型(整数型)にしなければいけなかった…(場合分けに注意!)

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?