luyencode / comments

Server lưu trữ bình luận trên Luyện Code
https://luyencode.net
6 stars 3 forks source link

https://oj.luyencode.net/problem/PTIT014 #702

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Chữ số tận cùng của 2^n - Luyện Code Online

https://luyencode.net/problem/PTIT014

quocbk commented 2 years ago

Đây là lời giải của mình đã AC. Nếu bạn đã cố gắng mà chưa làm được thì có thể tham khảo lời giải của mình.

Xem code AC

#include using namespace std; #define ll long long int main(){ ll n, s = 1; cin >> n; for(int i = 1; i <= n; i++){ s *= 2; } cout << s % 10; return 0; }

wind5293 commented 1 year ago

Đây là lời giải của mình đã AC. Nếu bạn đã cố gắng mà chưa làm được thì có thể tham khảo lời giải của mình.

Xem code AC

```cpp #include #define ll long long using namespace std; int main() { int N; cin >> N; if (N == 0) cout << "1"; else { int n = N % 4; if(n == 0) { ll res = pow(2, 4); cout << res % 10; } else { ll res = pow(2, n); cout << res % 10; } } } ```

sseu18042004 commented 1 year ago

nhớ là số tự nhiên là có n=0 nha mọi người, 2^0=1 :))

polopilo commented 1 year ago

DONE nhx ko bt cách share đáp án