View Code of Problem 3703

    #include <cstdio>  
    #include <cmath>  
    #include <cstdlib>  
    #include <cstring>  
    #include <vector>  
    #include <map>  
    #include <iostream>  
    #include <algorithm>  
    using namespace std;  
      
    #define LL __int64  
    const int maxn=5e5+20;  
    LL mod;  
    LL val[maxn],dp[maxn];  
      
    void fun(int n)  
    {  
        for(LL i=1;i<n;i++)//枚举因子  
        {  
            for(LL j=i;j<n;j+=i)//枚举含有因子的数  
            {  
                val[j]+=(j/i+1)*(j/i)/2;  
            }  
        }  
    }  
    void init()  
    {  
        mod=1;  
        mod=(mod<<32);  
        memset(val,0,sizeof(val));  
        fun(maxn);  
        dp[1]=1;  
        for(LL i=2;i<maxn;i++)//递推公式  
        {  
            dp[i]=dp[i-1]+val[i]*i;  
            dp[i]=dp[i]%mod;  
        }  
    }  
    int main()  
    {  
        init();  
        int n,tt=0,T;  
        scanf("%d",&T);  
        while(T--)  
        {  
            scanf("%d",&n);  
            printf("Case #%d: %I64d\n",++tt,dp[n]);  
        }  
        return 0;  
    }  
/*
Main.cc:11:16: error: '__int64' does not name a type
     #define LL __int64  
                ^
Main.cc:13:5: note: in expansion of macro 'LL'
     LL mod;  
     ^
Main.cc:11:16: error: '__int64' does not name a type
     #define LL __int64  
                ^
Main.cc:14:5: note: in expansion of macro 'LL'
     LL val[maxn],dp[maxn];  
     ^
Main.cc: In function 'void fun(int)':
Main.cc:11:16: error: '__int64' was not declared in this scope
     #define LL __int64  
                ^
Main.cc:18:13: note: in expansion of macro 'LL'
         for(LL i=1;i<n;i++)//枚举因子  
             ^
Main.cc:18:20: error: 'i' was not declared in this scope
         for(LL i=1;i<n;i++)//枚举因子  
                    ^
Main.cc:20:20: error: expected ';' before 'j'
             for(LL j=i;j<n;j+=i)//枚举含有因子的数  
                    ^
Main.cc:20:24: error: 'j' was not declared in this scope
             for(LL j=i;j<n;j+=i)//枚举含有因子的数  
                        ^
Main.cc:22:17: error: 'val' was not declared in this scope
                 val[j]+=(j/i+1)*(j/i)/2;  
                 ^
Main.cc: In function 'void init()':
Main.cc:28:9: error: 'mod' was not declared in this scope
         mod=1;  
         ^
Main.cc:30:16: error: 'val' was not declared in this scope
         memset(val,0,sizeof(val));  
                ^
Main.cc:32:9: error: 'dp' was not declared in this scope
         dp[1]=1;  
         ^
Main.cc:11:16: error: '__int64' was not declared in this scope
     #define LL __int64  
                ^
Main.cc:33:13: note: in expansion of macro 'LL'
         for(LL i=2;i<maxn;i++)//递推公式  
             ^
Main.cc:33:20: error: 'i' was not declared in this scope
         for(LL i=2;i<maxn;i++)//递推公式  
                    ^
Main.cc: In function 'int main()':
Main.cc:47:45: error: 'dp' was not declared in this scope
             printf("Case #%d: %I64d\n",++tt,dp[n]);  
                                             ^
*/

Double click to view unformatted code.


Back to problem 3703