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?

AtCoder Beginner Contest 467

0
Posted at

A - Obesity

問題文

体重[kg]÷身長[m]÷身長[m]
w / (h / 100) / (h / 100) >= 25.0
w * (100 / h) * (100 / h) >= 25.0
w * 100 * 100 >= 25.0 * h * h
C++
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0; i<(n); ++i)
#define repx(i,x,n) for(int i=x; i<(n); ++i)
#define fixed_setprecision(n) fixed << setprecision((n))
#define execution_time(ti) printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
#define pai 3.1415926535897932384
#define NUM_MAX 2e18
#define NUM_MIN -1e9
 
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }

int main() {
    double h, w;
    cin >> h >> w;

    if(w * 100 * 100 >= 25.0 * h * h){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
} 

B - Keep the Change

問題文

takeの時だけb-aを加算します。

        x -= b;
        y -= a;
        if(s == "take") x += b - a;
C++
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0; i<(n); ++i)
#define repx(i,x,n) for(int i=x; i<(n); ++i)
#define fixed_setprecision(n) fixed << setprecision((n))
#define execution_time(ti) printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
#define pai 3.1415926535897932384
#define NUM_MAX 2e18
#define NUM_MIN -1e9
 
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }

int main() {
    int n;
    cin >> n;

    int x = 10000, y = 10000;
    rep(i, n){
        int a, b;
        string s;
        cin >> a >> b >> s;

        x -= b;
        y -= a;

        if(s == "take") x += b - a;
    }
    cout << y - x << endl;

    return 0;
} 

C - Adjacent Sums (easy)

問題文

最初の値の奇数、偶数を決めると、その他の全ての値が決まります。

C++
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0; i<(n); ++i)
#define repx(i,x,n) for(int i=x; i<(n); ++i)
#define fixed_setprecision(n) fixed << setprecision((n))
#define execution_time(ti) printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
#define pai 3.1415926535897932384
#define NUM_MAX 2e18
#define NUM_MIN -1e9
 
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), aa(n), b(n-1);
    rep(i, n) cin >> a[i];
    rep(i, n) aa[i] = a[i];
    rep(i, n-1) cin >> b[i];

    vector<int> ans(2, 0);
    aa[0] = (aa[0] + 1) % 2;
    ans[1]++;

    rep(i, n-1){
        if((a[i] + a[i+1]) % 2 != b[i]){
            a[i+1]++;
            ans[0]++;
        }
        if((aa[i] + aa[i+1]) % 2 != b[i]){
            aa[i+1]++;
            ans[1]++;
        }
    }

    cout << min(ans[0], ans[1]) << endl;

    return 0;
} 

問題文

C++
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?