C. Hàm xét chia hết


Submit solution

Points: 50
Time limit: 1.0s
Memory limit: 256M

Problem type

Cho một số nguyên n. Hãy kiểm tra xem biểu thức n² + n có chia hết cho 6 hay không.

Đầu vào:

  • Một số nguyên n (-10⁶ ≤ n ≤ 10⁶)

Đầu ra:

  • In "THOA MAN" nếu (n² + n) chia hết cho 6
  • Ngược lại in "KHONG"

Testcase:

Input Output Giải thích
2 THOA MAN 2² + 2 = 6 → chia hết 6

Mã C++ minh hoạ:

#include <iostream>
using namespace std;

string kiemTra(int n) {
    int tong = _______;
    if (______ == 0)
        return "THOA MAN";
    else
        return "KHONG";
}

int main() {
    int n;
    cin >> n;
    cout << ______(n);
    return 0;
}

Comments

There are no comments at the moment.