Please turn JavaScript on
Latest LCOJ Comments icon

Latest LCOJ Comments

Want to stay in touch with the latest updates from Latest LCOJ Comments? That's easy! Just subscribe clicking the Follow button below, choose topics or keywords for filtering if you want to, and we send the news to your inbox, to your phone via push notifications or we put them on your personal page here on follow.it.

Reading your RSS feed has never been easier!

Website title: Trang chủ - LCOJ: Luyencode Online Judge

Is this your feed? Claim it!

Publisher:  Unclaimed!
Message frequency:  3.77 / day

Message History

include <bits/stdc++.h>

using namespace std ; int main () { int n ; cin >> n ;

vector <int> a(n) ; for (int i = 0 ; i < n ; i++ ){ cin >> a[i] ; } int d_t = 0 ; int d_p = 0 ; for (int i = 0 ; i < n ; i++ ){ if (a[i] == 1) { d_t++ ; } else { d_p++ ; } } cout << abs(d_t - d_p) ;

}


Read full story

Ý tưởng: Ta thử viết vài giá trị: 2^1 = 2 -> tận cùng 2 2^2 = 4 -> tận cùng 4 2^3 = 8 -> tận cùng 8 2^4 = 16 -> tận cùng 6 2^5 = 32 -> tận cùng 2 2^6 = 64 -> tận cùng 4 2^7 = 128 -> tận cùng 8 2^8 = 256 -> tận cùng 6 Ta thấy chữ số tận cùng lặp lại theo chu kỳ: 2-4-8-6 Vậy mình chỉ cần tính n % 4: Ra 1 thì in 2 Ra 2 thì in 4 Ra 3 thì in 8...


Read full story