PTIT014 - Chữ số tận cùng của 2^n

View as PDF

Submit solution

Points: 1.00 (partial)
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
C, C#, C++, Go, Java, Pascal, Perl, PHP, Python, Ruby, Rust, Scratch, Swift

Bạn hãy tìm chữ số tận cùng của ~2^n~.

Input

Gồm 1 số tự nhiên ~n~ (~n \le 60~).

Output

In ra một số nguyên duy nhất là kết quả của bài toán.

Sample

Input #1
4
Output #1
6

Problem source: CLB Lập Trình PTIT


Comments

Please read the guidelines before commenting.



  • 0
    sugardaddy  commented on Nov. 10, 2024, 2:29 p.m. edited

    nên sử dụng theo cách tư duy thông thường bằng cách lấy dư n cho 4,nếu chia hết cho 4 thì in ra 6 còn ngược lại thì sẽ lấy số dư nhân 2 rồi nhân với 6 sau chia dư cho 10(vì đôi khi bài toán sẽ cho n quá lớn)


    • 0
      sugardaddy  commented on Nov. 10, 2024, 2:32 p.m.

      à mà để ý n=0 nữa nhé


  • -3
    kietjumper  commented on Oct. 10, 2024, 4:15 p.m. edit 3
    cout<< static_cast<ll> (pow(2, n)) % 10;
    

    • -1
      kietjumper  commented on Nov. 11, 2024, 3:41 p.m.

      ll = long long


  • 0
    NTA  commented on Sept. 30, 2024, 8:33 a.m.

    Test hơi yếu thì phải


  • 1
    minhducyl156  commented on May 28, 2024, 3:00 p.m. edit 2

    $$Tìm.2^n->Code : pow(2,n) $$

    $$Nên-đặt -1 -biến- bằng- pow(2,n)->Code: p=pow(2,n)$$

    Kết quả cuối cùng : p chia lấy dư cho 10 -> Code: p%10;