把所有数据类型都改成long long还是不行,这和高精度有区别吗

P1009 [NOIP1998 普及组] 阶乘之和

qew12312 @ 2023-04-25 10:47:00

#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
long long er(long long i){
    long long we=1;
    for(int er=1;er<=i;er++){
        we*=er;
    }
    return we;
}
int main(){
    long long sd,sum=0,i;
    cin>>sd;
    for(i=1;i<=sd;i++){
        sum+=er(i);
    }
    cout<<sum;
    return 0;
}

by cannotdp @ 2023-04-25 11:03:43

显然有


by sail_with_pleasure @ 2023-04-25 11:41:03

@qew12312 long long支持大概4e18内的运算,高精不考虑时空复杂度的话无上限


by Even_If @ 2023-05-02 22:12:24

@qew12312 n=50的情况下答案是31035053229546199656252032972759319953190362094566672920420940313,long long显然不行,必须高精度。

当然我用的打表(doge

#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    string quq[60]={"0","1","3","9","33","153","873","5913","46233","409113","4037913","43954713","522956313","6749977113","93928268313","1401602636313","22324392524313","378011820620313","6780385526348313","128425485935180313","2561327494111820313","53652269665821260313","1177652997443428940313","27029669736328405580313","647478071469567844940313","16158688114800553828940313","419450149241406189412940313","11308319599659758350180940313","316196664211373618851684940313","9157958657951075573395300940313","274410818470142134209703780940313","8497249472648064951935266660940313","271628086406341595119153278820940313","8954945705218228090637347680100940313","304187744744822368938255957323620940313","10637335711130967298604907294846820940313","382630662501032184766604355445682020940313","14146383753727377231082583937026584420940313","537169001220328488991089808037100875620940313","20935051082417771847631371547939998232420940313","836850334330315506193242641144055892504420940313","34289376947494122614363304694584807557656420940313","1439295494700374021157505910939096377494040420940313","61854558558074209658512637979453093884758552420940313","2720126133346522977702138448994068984204397080420940313","122342346998826717539665299944651784048588130840420940313","5624964506810915667389970728744906677010239883800420940313","264248206017979096310354325882356886646207872272920420940313","12678163798554051767172643373255731925167694226950680420940313","620960027832821612639424806694551108812720525606160920420940313","31035053229546199656252032972759319953190362094566672920420940313"};
    int n;
    scanf("%d",&qwq);
    cout<<quq[qwq];
    return 0;
}

by Westbr00k @ 2023-05-06 13:09:29

@YXS_OIer 这表太吊了,%%%


by luolie0804 @ 2023-05-07 20:03:14

@noob114514 这表确实很吊。(能做出这表很牛)


by Wxks @ 2023-05-07 20:28:02

@YXS_OIer orz


by dingding2008 @ 2023-05-13 22:12:27

@luolie0804 CSDN上有,我开始做这道题的时候,我搜了


by Even_If @ 2023-05-14 12:42:24

@dingding2008

打了差不多5分钟,自己做的


by dingding2008 @ 2023-05-14 22:11:28

呵呵呵


by ycx114514 @ 2023-06-24 17:24:07

@YXS_OIer 时间复杂度o(1),完美解没毛病


|