2 5
9
就是给你l和r,让你求l到r中每一个数的因子数的个数
#include<stdio.h> #include<string.h> #include<math.h> #include<iostream> #include<algorithm> /* 补全成循环节,并循环至少两次 */ using namespace std; typedef long long ll; const int maxn=1e6+100; ///https://www.cnblogs.com/acm-epoch/p/13342227.html int a[10]={0,1,3,5,8,10}; ll solve(ll n){ if(n<=5) return a[n]; ll sum=0;ll i; for(i=1;i*i<=n;i++){ sum+=n/i-(i-1); } return sum*2-i+1; } int main(){ ll n,m; scanf("%lld%lld",&n,&m); printf("%lld\n",solve(m)-solve(n-1)); }
原文:https://www.cnblogs.com/lipu123/p/14616788.html