C/중간고사 대비 (2022 1학기)
[C 백준] 1350번 진짜 공간
Meaning_
2022. 4. 22. 11:43
728x90
반응형
https://www.acmicpc.net/problem/1350
1350번: 진짜 공간
첫째 줄에 파일의 개수 N이 주어진다. N은 50보다 작거나 같은 자연수이다. 둘째 줄에는 파일의 크기가 공백을 사이에 두고 하나씩 주어진다. 파일의 크기는 1,000,000,000보다 작거나 같은 음이 아닌
www.acmicpc.net
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable: 4996)
#include <stdio.h>
#include<stdbool.h>
long arr[51];
int main()
{
long cnt = 0;
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%ld", &arr[i]);
}
long byte;
scanf("%ld", &byte);
for (int i = 0; i < n; i++) {
int num = arr[i] / byte;
cnt += num * byte;
if (arr[i] % byte != 0) {
cnt += byte;
}
}
printf("%ld", cnt);
}
|
cs |
728x90
반응형