using namespace std ; int main () { int n ; cin >> n ;
while (n--) { int x ; cin >> x ; int h = 1 ; for (int i = 0 ; i < x ; i++ ){ if (h % 2 == 0) { h += 1 ; } else { h *= 2 ; } } cout << h << " " << endl ; } return 0 ;}
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!
using namespace std ; int main () { int n ; cin >> n ;
while (n--) { int x ; cin >> x ; int h = 1 ; for (int i = 0 ; i < x ; i++ ){ if (h % 2 == 0) { h += 1 ; } else { h *= 2 ; } } cout << h << " " << endl ; } return 0 ;}
CODE FULL AC CHO AE NHÁ=)))
#include <bits/stdc++.h> #include <map> using namespace std; #define ll long long #define ull unsigned long long #define pb push_back #define all(x) (x).begin(), (x).end() #define fi first #define se second #define FOR(i, a, b) for (int i = (a); i <= (b); ++i) #define ROF(i, a, b) for (int i = (a); i >= (b)...Hint:
Số đối xứng có n chữ số: chọn nửa đầu, nửa sau lật ngược lại. Nếu n lẻ: chọn $$(n+1)/2$$ chữ số, chữ số đầu ≠ 0. Nếu n chẵn: chọn n/2 chữ số, chữ số đầu ≠ 0. Công thức: $$9 * 10^((n-1)/2)$$.
code tham khảo (c++)
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int ...hint
Hàm dx(x): kiểm tra số đối xứng (palindrome).
Chuyển số thành xâu.
So sánh ký tự đầu và cuối, lặp vào trong.
main:
Đọc vô hạn các cặp l, r cho đến khi hết file.
Với mỗi cặp, duyệt từ l đến r, đếm số đối xứng.
In kết quả.
code tham khảo (c++)
#include <bits/stdc++.h> using namespa...