2
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?

AtCoder434の感想と自分が解いたところまでの解説を書いていきます
今回はAをpython,C++,java, Bをpython,C++でときます
AtCoder Beginner Contest 434
今回もちゃんと解説書きます

1.感想

A問題:
今回は簡単で良かった
B問題:
まあまあ簡単だった
C問題:
できそうでできない
D問題:
できそうでできない

2.結果

image.png
まあ耐えたのかな?

3.解説

A問題

kgをgにしてからBで切り上げ

C++での解法

#include <iostream>
using namespace std;

int main(){
    int W, B;
    cin >> W >> B;
    cout << W*1000/B+1 << endl;
    return 0;
}

pythonでの解法

from math import ceil
W, B = map(int, input().split())
print(W*1000//B+1)

javaでの解法

import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner javain = new Scanner(System.in);
        int W = javain.nextInt();
        int B = javain.nextInt();
        System.out.println(W*1000/B+1);
    }
}

B問題 Bird Watching

入力してそれを種類で分けて
そこの総和をその要素数で割る
特にC,C++などは表示に気をつける

#include <bits/stdc++.h>
using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> count(M);
    
    for (int i = 0; i < N; i++){
        int a, b;
        cin >> a >> b;
        count[a-1].push_back(b);
    }
    
    for (int i = 0; i < M; i++){
        double sum = 0;
        for(int j, count[i]) sum += (double)j;
        printf("%.20lf\n", sum/(double)count[i].size());
    }
}

pythonでの解法

N, M = map(int, input().split())
count = [[] for _ in range(M)]

for i in range(N):
    a, b = map(int, input().split())
    count[a-1].append(b)

for i in range(M):
    print(sum(count[i])/len(count[i]))
2
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
2
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?