Số đẹp

View as PDF

Submit solution

Points: 0.01 (partial)
Time limit: 1.0s
Memory limit: 256M
Input: sodep.inp
Output: sodep.out

Author:
Problem type
Allowed languages
C, C++, Go, Java, Kotlin, Pascal, PyPy, Python, Rust, Scratch

~T~ là tổng các chữ số của ~N~. Số ~N~ được gọi là số đẹp nếu hàng đơn vị của ~T~ là số ~9~. Ví dụ số ~18~ là số đẹp vì có ~T = 1 + 8 = 9~.

Cho một số ~N~, hỏi ~N~ có phải là số đẹp hay không?

Input

Từ tệp văn bản SODEP.INP chứa một số tự nhiên ~N~ duy nhất (~0 \leq N \leq 10^9~).

Output

Đưa ra tệp SODEP.OUT số 1 nếu ~N~ là số đẹp, ngược lại ghi số 0.

Sample Input 1

27

Sample Output 1

1

Sample Input 2

111

Sample Output 2

0

Comments

Please read the guidelines before commenting.



  • 3
    HieuTrong  commented on Feb. 1, 2026, 3:48 p.m.

    Bài này rất hợp cho các bạn mới vài note: thay vì nhập N vào bài dưới dạng số thì nên dùng xâu để tính tổng chữ số dễ hơn, vì for tiện hơn, mà với N<=1e9 thì làm như nào chả đc


  • 3
    Dangcoder  commented on Nov. 12, 2025, 12:33 p.m.

    why we have to use string while n <= 1e9?


  • 3
    namta1082012  commented on Sept. 26, 2025, 2:17 p.m.

    MPC


  • 3
    ngoccaidu2008  commented on Sept. 19, 2025, 3:19 p.m.

    bài này dùng số học


  • -8
    quangvukts  commented on Sept. 1, 2025, 2:16 p.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -4
    quangvukts  commented on Sept. 1, 2025, 2:16 p.m.

    Pls downvote


  • -6
    quangvukts  commented on Sept. 1, 2025, 2:16 p.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • 2
    PhuocThien  commented on Aug. 17, 2025, 11:52 a.m.

    code nha moi nguoi:

    include <bits/stdc++.h>

    using namespace std; long long kq(long long n) { long long so=0; while(n>0) { so=so+n%10; n=n/10; } return so; } int main() { ifstream cin("sodep.inp"); ofstream cout("sodep.out"); long long n; cin>>n; if(kq(n)==9||kq(n)%10==9)cout<<"1"; else cout<<"0"; return 0; }


  • -11
    NTatNghia_2013  commented on April 19, 2025, 1:55 p.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -11
    NTatNghia_2013  commented on April 19, 2025, 1:55 p.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -11
    NTatNghia_2013  commented on April 19, 2025, 1:54 p.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • 5
    tranbaphu098  commented on April 17, 2025, 11:24 a.m.

    with open("SODEP.INP", "r") as f: n = int(f.read().strip())

    Tính tổng chữ số của N

    total = sum(int(digit) for digit in str(n))

    Kiểm tra có phải số đẹp không

    is_beautiful = 1 if total % 10 == 9 else 0

    Ghi kết quả ra file

    with open("SODEP.OUT", "w") as f: f.write(str(is_beautiful))


  • -2
    tranbaphu098  commented on April 17, 2025, 11:21 a.m.

    help me