整除

题目描述

牛牛对整除非常感兴趣。牛牛的老师给他布置了一道题:牛牛的老师给出一个n,然后牛牛需要回答出能被1到n之间(包括1和n)所有整数整除的最小的数。牛牛犯了难,希望你能编程帮他解决这个问题。

输入描述

输入包括一个整数n(1<=n<=100000)

输出描述

输出一个整数,即满足要求的最小整数。答案可能很大,请输出这个整数对于987654321取模的结果

输入示例

3

输出示例

6

#include<bits/stdc++.h>
using namespace std;
const int maxn=100000+5;
int tmp[maxn];
int n;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){
        int k=i;
        for(int j=2;j*j<=n;j++){
            int s=0;
            while(k%j==0){
                s++;
                k/=j;
            }
            tmp[j]=max(tmp[j],s);
        }
        if(k>1)
            tmp[k] = max(tmp[k],1);
    }
    long long res=1;
    for(int i=1;i<=100000;i++){
        for(int j=0;j<tmp[i];j++){
            res = res*i%987654321;
        }
    }
    cout<<res<<endl;
    return 0;
}

 

posted @ 2019-01-27 10:08  strawqqhat  阅读(186)  评论(0编辑  收藏  举报
#home h1{ font-size:45px; } body{ background-image: url("放你的背景图链接"); background-position: initial; background-size: cover; background-repeat: no-repeat; background-attachment: fixed; background-origin: initial; background-clip: initial; height:100%; width:100%; } #home{ opacity:0.7; } .wall{ position: fixed; top: 0; left: 0; bottom: 0; right: 0; } div#midground{ background: url("https://i.postimg.cc/PP5GtGtM/midground.png"); z-index: -1; -webkit-animation: cc 200s linear infinite; -moz-animation: cc 200s linear infinite; -o-animation: cc 200s linear infinite; animation: cc 200s linear infinite; } div#foreground{ background: url("https://i.postimg.cc/z3jZZD1B/foreground.png"); z-index: -2; -webkit-animation: cc 253s linear infinite; -o-animation: cc 253s linear infinite; -moz-animation: cc 253s linear infinite; animation: cc 253s linear infinite; } div#top{ background: url("https://i.postimg.cc/PP5GtGtM/midground.png"); z-index: -4; -webkit-animation: da 200s linear infinite; -o-animation: da 200s linear infinite; animation: da 200s linear infinite; } @-webkit-keyframes cc { from{ background-position: 0 0; transform: translateY(10px); } to{ background-position: 600% 0; } } @-o-keyframes cc { from{ background-position: 0 0; transform: translateY(10px); } to{ background-position: 600% 0; } } @-moz-keyframes cc { from{ background-position: 0 0; transform: translateY(10px); } to{ background-position: 600% 0; } } @keyframes cc { 0%{ background-position: 0 0; } 100%{ background-position: 600% 0; } } @keyframes da { 0%{ background-position: 0 0; } 100%{ background-position: 0 600%; } } @-webkit-keyframes da { 0%{ background-position: 0 0; } 100%{ background-position: 0 600%; } } @-moz-keyframes da { 0%{ background-position: 0 0; } 100%{ background-position: 0 600%; } } @-ms-keyframes da { 0%{ background-position: 0 0; } 100%{ background-position: 0 600%; } }