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/PTIT007 #798

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Chi tiết bài tập - Luyện Code Online

https://oj.luyencode.net/problem/PTIT007

AnnNaa0511 commented 1 year ago

Gợi ý: Chuyển x từ hệ 10 sang hệ 3. Nếu số hệ 3 chỉ gồm các số hạng 1 và 0 thì x là số đẹp.

Xem code AC

```cpp #include using namespace std; bool test_nice(long n){ while(n>0){ if(n%3==2) return false; n=n/3; } return true; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); int F[20001],k=0; for(int i=1;i<=20000;i++){ if(test_nice(i)) F[k++]=i; } int T,n; cin>>T; while(T--){ cin>>n; int pos= lower_bound(F,F+k,n)-F; cout<

ThuanNqt commented 1 year ago

cách làm dễ hiểu (^_^)

Xem code AC

#include using namespace std; typedef long int ll; //THUẬN IT2-HUST set se;//dùng set để lưu các số đẹp //hàm check số đẹp int check(int x){ while(x!=0){ if(x%3==2) return 0; x/=3; } return 1; } ll sodep(){ for(int i=1;i<33333;i++){ if(check(i)){ se.insert(i);//lưu các số đẹp vào trong set } } } int main(){ sodep(); int n;cin>>n; while(n--){ int x;cin>>x; auto it=se.lower_bound(x);//tìm số đẹp nhỏ nhất >=x cout<<*it<

husofshikamaru commented 1 year ago

Code Java đã accept cho ai cần tham khảo : https://fnote.net/notes/mDh79N