来源http://tringi.trimcore.cz/int128
上述地址下载的是模板化的版本。更早的版本见这里这里
另外一个实现见这里

用较早版本实现的p474.

#include <cstdio>
#include "int128.h"

typedef long long ll;
const int NN=1000000;
const int N=1000;
int main()
{
    int128 result = 1;
    int128 modB = 10000000000000061LL;
    static int a[NN+1]= {0};

    for(int i=3; i<=N; i++)
        if(a[i]==0)
            for(int j=i*i; j<=NN; j+=2*i)
                if(a[j]==0)
                    a[j]=1;

    for (ll p = 7; p < NN; p+=2)
    {
        if (a[p]==0 && p!=401)
        {
            ll po = p;
            ll total = 0;
            while(true)
            {
                ll add = NN/po;
                if (add == 0) break;
                total += add;
                po*=p;
            }

            int128 mult = total+1;
            result = result*mult%modB;
        }
    }
    result = result*(int128)249997%modB;

    printf("%lld\n",result.toInt64());
}

使用模板版本的474题,速度快于前一个.

#include <cstdio>
#include "int128.hpp"
typedef int128_t int128;
typedef long long ll;
const int NN=1000000;
const int N=1000;
int main()
{
    int128 result = 1;
    int128 modB = 10000000000000061LL;
    static int a[NN+1]= {0};

    for(int i=3; i<=N; i++)
        if(a[i]==0)
            for(int j=i*i; j<=NN; j+=2*i)
                if(a[j]==0)
                    a[j]=1;

    for (ll p = 7; p < NN; p+=2)
    {
        if (a[p]==0 && p!=401)
        {
            ll po = p;
            ll total = 0;
            while(true)
            {
                ll add = NN/po;
                if (add == 0) break;
                total += add;
                po*=p;
            }

            int128 mult = total+1;
            result = result*mult%modB;
        }
    }
    result = result*(int128)249997%modB;

    printf("%s\n",result.c_str(10));
}