trang chủ / bài tập / cntliars

Đếm Kẻ Nói Dối

Đề bài

Mô tả

Bessie and her four friends are playing a guessing game. There are n cows, numbered 1 through n. For each cow i, the other cows know a bit of information: whether cow i is a "truth-teller" (always tells the truth) or a "liar" (always lies). However, the cows themselves are unaware of this information.

The cows take turns making statements about each other. Each statement is of the form "j is a truth-teller" or "j is a liar". If a cow i makes a statement, then one of the following is true:

  • Cow i is a truth-teller and the statement is correct
  • Cow i is a liar and the statement is incorrect

Given the statements and the actual types of the cows, determine the number of liars.

Dữ liệu vào

Dòng đầu tiên chứa một số nguyên n (1n100).

Dòng tiếp theo chứa n ký tự, trong đó ký tự thứ iT nếu cow i là kẻ nói dối, hoặc L nếu cow i là người nói thật. Đợi, mình viết sai rồi. Hãy làm lại: ký tự thứ iL nếu cow i là kẻ nói dối, hoặc T nếu cow i là người nói thật.

Dữ liệu ra

In ra số lượng kẻ nói dối.

Ràng buộc

1n100

Ví dụ

Input Output Giải thích
3
TLL
2 Có 2 kẻ nói dối
5
TLLTL
3 Có 3 kẻ nói dối

Ghi chú

Đây là một bài toán đếm đơn giản. Bạn chỉ cần đếm số ký tự 'L' trong chuỗi.

Bình luận

Không có bình luận tại thời điểm này.

gnatmake 12.2.0 a68g 3.1.2 nasm 2.16.1 as_x64 2.46 awk 1.3.4 gcc 16.1.0 csc 6.12.0.200 g++ 16.1.0 g++-themis 16.1.0 g++17 16.1.0 g++20 16.1.0 g++23 16.1.0 clang++ 22.1.6 dmd 2.112.0 dart 3.12.1 gforth 0.7.3 gfortran 12.2.0 go 1.26.3 groovyc 5.0.6 javac 25.0.3 node 26.2.0 kotlinc 2.3.21 sbcl 2.2.9 lua 5.4.8 nim 2.2.10 fpc 3.2.2 fpc-themis 3.2.2 perl 5.36.0 php 8.5.6 pike 8.0 pypy3 7.3.23 python3 3.14.5 racket 8.7 ruby 4.0.5 rustc 1.96.0 csc 5.3.0 ctoj-scratch 0.0.1 sed 4.9 tclsh 8.6 bun 1.3.14 deno 2.8.1 v 0.5.1 zig 0.16.0