結果
| 問題 | 
                            No.2269 eN!の整数部分の下1桁
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2023-07-23 18:18:47 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 206 ms / 2,000 ms | 
| コード長 | 669 bytes | 
| コンパイル時間 | 937 ms | 
| コンパイル使用メモリ | 95,944 KB | 
| 最終ジャッジ日時 | 2025-02-15 18:35:46 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 23 | 
ソースコード
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<int,int> P;
typedef pair<int,P> PP;
const ll MOD=1e9+7;
ll f(ll n){
    if(n==0) return 2;
    ll res=0;
    for(ll i=max(0LL,n-4);i<=n;i++){
        ll c=1;
        for(ll j=i+1;j<=n;j++){
            c*=j;
            c%=10;
        }
        res+=c;
        res%=10;
    }
    return res;
}
int main(){
    int T;
    cin>>T;
    for(int t=0;t<T;t++){
        ll N;
        cin>>N;
        cout<<f(N)<<endl;
    }
}