LTOL


Submit solution

Points: 1 (partial)
Time limit: 1.0s
Memory limit: 67M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, C, C++, C11, CLANG, CLANGX, Classical, COBOL, Coffee, CSC, D lang, DART, F95, FORTH, Fortrn, GAS32, GO, Haskell, Itercal, Java, kotlin, LEAN, LISP, LUA, MONOVB, Nasm, OCAML, Pascal, Perl, php, PIKE, prolog, Pypy, Python, Ruby 2, RUST, Scala, SCM, SED, SWIFT, TCL, TUR, V8JS, VB, ZIG

Bạn hãy lập trình thực hiện thuật toán sau:

Nhập vào số nguyên dương n
Với mỗi số i từ 1 tới n:
    Nếu i lẻ thì xuất ra số i
    Nếu i chẵn thì xuất ra kí tự 'L'
    Nếu i chia hết cho 4 thì xuất ra kí tự 'T'
    Nếu i chia hết cho 8 thì xuất ra kí tự 'O'
    Nếu i chia hết cho 16 thì xuất ra kí tự 'L'
    Xuống dòng
Thoát chương trình.

Ví dụ

Đầu vào:

17

Đầu ra:

1
L
3
LT
5
L
7
LTO
9 
L 
11
LT 
13
L
15
LTOL 
17

Ghi chú: \((1 \le n \le 1000)\)

QDUY

Comments


  • 0
    konchan  commented on April 1, 2024, 7:16 p.m.

    import java.util.Scanner;

    public class ltol { public static void main(String[] args){ Scanner input = new Scanner(System.in); int n = input.nextInt(); for(int i=1;i<=n;i++){ if(i%2!=0){ System.out.print(i); } if(i%2==0){ System.out.print("L"); } if(i%4==0){ System.out.print("T"); } if(i%8==0){ System.out.print("O"); } if(i%16==0){ System.out.print("L"); } System.out.println(""); } } }


  • -5
    Giáp12  commented on Sept. 30, 2023, 12:34 p.m.

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


  • 0
    tiendepzai  commented on Aug. 20, 2023, 6:21 a.m. edited

    o?o


  • 0
    TICHPX  commented on Dec. 21, 2022, 3:22 p.m. edited

    cũng là "lập trình on line" mà trông nó lạ lắm