1 #include <iostream> 2 using namespace std; 3 int main() 4 {long long s=0,t=1; 5 int m,n; 6 cin>>n; 7 for (m=1;m<=n;m++) 8 { 9 t=t*m; 10 s=s+t; 11 } 12 cout<<s<<endl; 13 return 0; 14 }
时间: 2024-10-05 05:07:10
1 #include <iostream> 2 using namespace std; 3 int main() 4 {long long s=0,t=1; 5 int m,n; 6 cin>>n; 7 for (m=1;m<=n;m++) 8 { 9 t=t*m; 10 s=s+t; 11 } 12 cout<<s<<endl; 13 return 0; 14 }