結果

問題 No.2269 eN!の整数部分の下1桁
ユーザー MarioYC
提出日時 2023-04-14 22:05:33
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 216 ms / 2,000 ms
コード長 408 bytes
コンパイル時間 1,811 ms
コンパイル使用メモリ 192,092 KB
最終ジャッジ日時 2025-02-12 06:45:03
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int solve(ll n){
    if(n <= 1) return 2;
    int d = 0;
    ll aux = 1;
    for(int i = 0;i < 5 && n - i >= 0;++i){
        d = (d + aux) % 10;
        aux = aux * (n - i) % 10;
    }
    return d;
}

int main(){
    int T;
    cin >> T;
    ll N;
    while(T--){
        cin >> N;
        cout << solve(N) << '\n';
    }
    return 0;
}
0