#include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<b;i++) #define rrep(i,a,b) for(int i=a;i>=b;i--) #define ll long long #define take(n) ll int n;cin>>n #define mp(a,b) make_pair(a,b) #define pb(a) push_back(a) using namespace std; int main() { // Zubin Shah int N; cin>>N; while(N--) { take(n); vector<int> vect; vect.pb(1); ll carry=0; int number_of_digits=1; rep(i,2,n+1){ rep(j,0,number_of_digits){ ll temp=(vect[j]*i)+carry; vect[j]=temp%10; carry=temp/10; } while(carry>0){ ll temp=carry%10; vect.pb(temp); carry/=10; number_of_digits++; } } rrep(i,number_of_digits-1,0){ cout<<vect[i]; } cout<<endl; } return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter