Số tam giác

View as PDF

Submit solution

Points: 100.00 (partial)
Time limit: 1.0s
Memory limit: 1G
Input: stdin
Output: stdout

Author:
Problem type
Allowed languages
C, C++, GAS64, Pascal, Perl, PHP, Python, Sed, TCL, Text

Một số được gọi là "số tam giác" nếu ta có thể biểu diễn nó dưới dạng lưới hình tam giác gồm các điểm sao cho các điểm tạo thành một tam giác đều, tức là hàng đầu tiên có một điểm, hàng thứ 2 có 2 điểm, hàng thứ ba có 3 điểm,... Các số tam giác bắt đầu là 1, 3 (1+2), 6 (1+2+3), 10 (1+2+3+4),....

Cho biết số nguyên dương ~N~, hãy cho biết ~N~ có phải là số tam giác hay không?

Đầu vào: Dòng đầu tiên chứa số nguyên ~T~ cho biết số bộ dữ liệu cần kiểm tra. Mỗi bộ dữ liệu gồm một dòng chứa số nguyên ~N~ duy nhất.

Đầu ra: Ứng với mỗi bộ dữ liệu đầu vào, cần in ra một dòng chứa số ~1~ nếu ~N~ là số tam giác, ngược lại in ra ~0~.

Ràng buộc: ~1 <= T <= 100~; ~1 <= N~ <= ~10^7~

Ví dụ:
Input:
5
3
4
6
55
345
Output:
1
0
1
1
0

Comments

Please read the guidelines before commenting.



  • -2
    Ductinh69420  commented on Sept. 26, 2022, 5:21 a.m.

    Hi, I’m Saul Goodman. Did you know that you have rights? The Constitution says you do. And so do I. I believe that until proven guilty, every man, woman, and child in this country is innocent. And that’s why I fight for you, Albuquerque! Better call Saul!Hi, I’m Saul Goodman. Did you know that you have rights? The Constitution says you do. And so do I. I believe that until proven guilty, every man, woman, and child in this country is innocent. And that’s why I fight for you, Albuquerque! Better call Saul!Hi, I’m Saul Goodman. Did you know that you have rights? The Constitution says you do. And so do I. I believe that until proven guilty, every man, woman, and child in this country is innocent. And that’s why I fight for you, Albuquerque! Better call Saul


  • -1
    anhtuan2007  commented on Sept. 20, 2022, 3:09 p.m.

    iloveamelia