标签:har getc clu div pac space png img 目录
超级大水题,而且时间给的还是5s(???),书上给的难度还是中(???)。
枚举倍数base,枚举每个数i,每次增加base,枚举到的i的个数就+1。
#include <cstdio>
#include <iostream>
using namespace std;
void read(int &n){
int num=0,w=1;
char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-') w=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
num=num*10+ch-'0';
ch=getchar();
}
n=num*w;
}
const int maxn=1e7+5;
int c,n,s,e,k,num[maxn];
void init(){
for(int base=1;base<=maxn;base++)//枚举倍数
for(int i=base;i<=maxn;i+=base)
num[i]++;
}
int main(){
init();
read(c);
while(c--){
read(n);read(s);read(e);
k=0;
for(s;s<=e;s++) if(num[s]==n) k++;
printf("%d\n",k);
}
return 0;
}
标签:har getc clu div pac space png img 目录
原文地址:https://www.cnblogs.com/saitoasuka/p/10353315.html