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/CRED #735

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://luyencode.net/problem/CRED

minhchi1509 commented 2 years ago

Đề bài phải sửa lại thành: "có bao nhiêu số nhỏ hơn hoặc bằng m".

NguyenKhacDuong01 commented 2 years ago

cho mình hỏi test 11 là gì vậy ạ

vanhhn commented 1 year ago

code AC https://ideone.com/cNmiLe

danh2006 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

#include using namespace std; int sum(int n){ int sotachra = 0, sum = 0; for(;n!=0;){ int sotachra = n%10; sum+=sotachra; n/=10; } return sum; } int main(){ int a, b; cin >> a >> b; int ans = a, cnt = 1; for(int i=0;i<10000;i+=1){ cnt++; ans+=sum(ans); if(ans==b){ cout << cnt; break; }else if(ans>b){ cout << cnt-1; break; } } }