きままにものづくり

日々の気付いたことなんかを書いてます。

ARCのA問題を解いてみた

こんばんは、even_ekoです。
今日は、風邪も治ったのでイラスト開発に専念しました。
なめらかな線を描けるように、補正を実装したのですがうまくいきませんでした。
なので、AtCoderのA問題を載せます。

#001のA問題

はじめは、ARC#001のA問題です。

#include<iostream>
#include<vector>

int main(){
int N,max_correct,min_correct;
    std::vector <int> count(4);
    std::cin >> N;
char c[100];
for(int i = 0; i < N ;++i){
        std::cin >> c[i];
switch(c[i]){
            case'1':
                ++count[0];
                break;
            case'2':
                ++count[1];
                break;
            case'3':
                ++count[2];
                break;
            case'4':
                ++count[3];
                break;
}
}
    
    max_correct = min_correct = count[0];
    for (int i=0; i<4; i++) {
        if (max_correct<count[i]) 
            max_correct = count[i];
        if (min_correct>count[i]) 
            min_correct = count[i];
    }

    std::cout << max_correct << ' ' << min_correct << '\n';
    
return0;
}

ベクトルを使う必要はほとんどないのですが、勢いで使ってます。

#002のA問題

次は、ARC#002のA問題です。

#include <iostream>
#include <vector>

int main(int argc, const char * argv[])
{
    int year;
    bool leapYear = false;
    std::cin >> year; 
    
    if (!(year%4))
        leapYear = true;
    if (!(year%100))
        leapYear = false;
    if (!(year%400))
        leapYear = true;
        
    if (leapYear){
        std::cout << "YES" << '\n';
    } else {
        std::cout << "NO" << '\n';
    }
    return 0;
}

400で割り切れる方が優先されるので、複雑な処理をする必要もないです。