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/SPPH #688

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

SỐ PHONG PHÚ - Luyện Code Online

https://luyencode.net/problem/SPPH

quocbk commented 2 years 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; #define ll long long const int x = 100005; ll s[x + 10]; ll l, r, ans; int main(){ for(ll i = 1; i * 2 <= x; i++){ for(ll j = i * 2; j <= x; j += i){ s[j] = s[j] + i; } } cin >> l >> r; for(ll i = l; i <= r; i++){ if(s[i] > i) ans++; } cout << ans; return 0; }