标签:
2 3 4
2 6 12
题解:简单大数,注意要先处理下;只需要大数相乘就可以了;
代码:
#include<cstdio> #include<iostream> #include<cmath> #include<algorithm> #include<cstring> #include<queue> using namespace std; const int INF=0x3f3f3f3f; #define mem(x,y) memset(x,y,sizeof(x)) #define SI(x) scanf("%d",&x) #define PI(x) printf("%d",x) typedef long long LL; int gcd(int a,int b){return b==0?a:gcd(b,a%b);} int ans[110]; int s[110]; int main(){ int n; while(~SI(n)){ int tp=1; s[0]=1; for(int i=1;i<=n;i++){ s[i]=i; for(int j=0;j<i;j++) s[i]=s[i]/gcd(s[j],s[i]); } ans[0]=1; for(int i=1;i<=n;i++){ int temp=0; for(int j=0;j<tp;j++){ temp=ans[j]*s[i]+temp; ans[j]=temp%10; temp/=10; } while(temp){ ans[tp++]=temp%10; temp/=10; } } for(int i=tp-1;i>=0;i--)printf("%d",ans[i]);puts(""); } return 0; }
标签:
原文地址:http://www.cnblogs.com/handsomecui/p/5236192.html