Posted in 2017 PacNW, ACM-ICPC

2017 PacNW C Fear factoring

/* 11/12/2017
*/


#include
#include 
using namespace std;

int main() {
	long long a,b;
	cin >> a >> b;
	long long tmp = sqrt(b);
	long long ans = 0;
	for (long long i = 1; i <= tmp; i++) {
		long long lb = max(tmp, (a-1) / i) + 1;
		long long ub = max(tmp, b / i);
		ans += i * (b / i - (a-1)/ i) + (lb + ub) * (ub - lb + 1) / 2;
	}
	cout << ans;
	return 0;
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s