본문 바로가기

Competition/codeforces

Codeforces Round #511 (Div. 2) A. Little C Loves 3 I

A. Little C Loves 3 I

https://codeforces.com/problemset/problem/1047/A


n을 3개의 숫자로 나누는데, 3의 배수가 있어서는 안된다.

1, 1, n-2로 나누는데, n-2가 3의 배수라면 1, 2, n-3으로 나눠주자.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <bits/stdc++.h>
using namespace std;
 
int n, a, b, c;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
    cin >> n;
    a = b = 1;
    c = n - 2;
    if (c % 3 == 0) {
        c--;
        b += 1;
    }
    cout << a << ' ' << b << ' ' << c;
    return 0;
}
cs