https://www.acmicpc.net/problem/10845


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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <queue>
#include <stdio.h>
#include <iostream>
#include <string>
 
using namespace std;
 
int main() {
    int N;
    cin >> N;
    string input;
    queue<int> q;
    for (int i = 0; i < N; i++) {
        cin >> input;
        if (input == "push") {            //push
            int num;
            cin >> num;
            q.push(num);
            //printf("%d\n", num); No print, if push.
        }
        else if (input == "front") {    //front
            if (q.empty() == 1)
                printf("-1\n");
            else
                printf("%d\n", q.front());
        }
        else if (input == "back") {        //back
            if (q.empty() == 1) {
                printf("-1\n");
            else
                printf("%d\n", q.back());
        }
        else if (input == "size")        //size
            printf("%d\n", q.size());
        else if (input == "pop") {        //pop
            if (q.empty() == 1)
                printf("-1\n");
            else {
                printf("%d\n", q.front());
                q.pop();
            }
        }
        else if (input == "empty")        //empty
            printf("%d\n", q.empty());
    }
    return 0;
}
cs


https://www.acmicpc.net/problem/2839


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
#include<iostream>
using namespace std;
 
int main() {
    int input;
    int a = , b = 0;
 
    cin >> input;
 
    if (input == || input == 7) {
        cout << -1;
        return 0;
    }
 
    while (input > 0) {
 
        if (input % == 0) {
            a = input / 5;
            break;
        }
 
        else {
            input = input - 3;
            b++;
        }
    }
    cout << a + b << endl;
}
cs

Problem

Mirko works in a sugar factory as a delivery boy. He has just received an order: he has to deliver exactly N kilograms of sugar 

to a candy store on the Adriatic coast. Mirko can use two types of packages, the ones that contain 3 kilograms, and the ones 

with 5 kilograms of sugar.

Mirko would like to take as few packages as possible. For example, if he has to deliver 18 kilograms of sugar, 

he could use six 3-kilogram packages. But, it would be better to use three 5-kilogram packages, and one 3-kilogram package,

 resulting in the total of four packages.

Help Mirko by finding the minimum number of packages required to transport exactly N kilograms of sugar.

Input

The first and only line of input contains one integer N (3 ≤ N ≤ 5000).

Output

The first and only line of output should contain the minimum number of packages Mirko has to use. If it is impossible 

to deliver exactly N kilograms, output -1.




https://www.acmicpc.net/problem/11718


<Method 1>

1
2
3
4
5
6
7
8
9
10
#include <stdio.h>
#pragma warning(disable : 4996)
 
int main() {
    char a;
 
    for (char a; ~scanf("%c"&a); printf("%c", a));
 
    return 0;
}
cs




<Method 2>

1
2
3
4
5
6
7
8
9
10
11
#include <stdio.h>
#pragma warning(disable : 4996)
 
int main() {
    char a;
 
    while (scanf("%c"&a) != -1)
        printf("%c", a);
 
    return 0;
}
cs


+ Recent posts