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/BEAUTIFUL #839

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

Đảo ngược số - Luyện Code Online

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

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 #define ll long long using namespace std; int reversed(ll n){ ll sotachra = 0, sum = 0; for(;n!=0;){ sotachra=n%10; sum=(sum*10)+sotachra; n/=10; } return sum; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll a, b, c; cin >> a >> b >> c; ll cnt = 0; for(ll i=a;i<=b;i++){ if(abs(i-reversed(i))%c==0){ cnt++; } } cout << cnt << endl; }