ZCMU—1611

    xiaoxiao2021-12-14  20

    1611: 大四下之回来看看

    Time Limit: 1 Sec   Memory Limit: 128 MB [ Submit][ Status][ Web Board]

    Description

    今天你回来了,看到了菜鸟学弟在算一个函数,函数是F(x):表示x的所有因子和。G(L,R):表示区间[L,R]的f(x)的和《L<=x<=R》。你看不下去学弟一个一个的算,于是你写了个程序给你的学弟。

    Input

    第一行是n(-1结束输入)

    接下来是n行 ,每行一对数L,R

    <范围在[1,100000]>

    Output

    输出答案对520623取模

    Sample Input

    1 5 6 -1

    Sample Output

    18

    【分析】

    也没啥大问题...预处理就好.. 【代码】 #include <stdio.h> #include <math.h> #include <string.h> int main() {     int f[100100]={0};     f[1]=1;f[2]=4;     for (int i=3;i<=100000;i++)     {     int sum=0;     int j;     for (j=1;j<sqrt(i);j++)     if (i%j==0)     sum+=(j+i/j)R0623;     if (j*j==i) sum+=j;     f[i]=(f[i-1]+sum)R0623; } int n;scanf("%d",&n); while (n!=-1) { for (int i=0;i<n;i++) { int x,y;scanf("%d %d",&x,&y); int ans=f[y]-f[x-1]+520623; ans%=520623; printf("%d\n",ans); } scanf("%d",&n); } return 0; }
    转载请注明原文地址: https://ju.6miu.com/read-970599.html

    最新回复(0)