50分求助

P1009 [NOIP1998 普及组] 阶乘之和

Aimtpy1m @ 2023-07-13 13:19:32

#include<bits/stdc++.h>
using namespace std;
int n;
unsigned long long ans=0;
unsigned long long ans1=1;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        ans1=1;
        for(int j=1;j<=i;j++){
            ans1*=j;
            //cout<<"ans1:"<<ans1<<endl; 
        }
        ans+=ans1;
        //cout<<"ans:"<<ans<<endl;
    }
    cout<<ans<<endl;
    return 0;
}

by onlyfiee @ 2023-07-13 13:59:31

@TLE_MLE

use namespace 高精度;


|