結果

問題 No.2269 eN!の整数部分の下1桁
ユーザー hiro71687k
提出日時 2023-04-15 00:40:49
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 855 bytes
コンパイル時間 4,109 ms
コンパイル使用メモリ 252,576 KB
最終ジャッジ日時 2025-02-12 08:33:42
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10 WA * 3 TLE * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll inf=144494;
ll mod=1000000007;
int main(){
    ll t;
    cin >> t;
    vector<ll>ans;
    for (ll o = 0; o < t; o++)
    {
        ll n;
        cin >> n;
        if (n==1)
        {
            ans.push_back(2);
            continue;
        }
        
        ll x=1;
        for (ll i = 1; i <=n; i++)
        {
            x*=i;
            x%=10;
        }
        ll a=x*2;
        a%=10;
        ll y=1;
        a+=1;
        a%=10;
        for (ll i = n; i >2; i--)
        {
            y*=i;
            y%=10;
            a+=y;
            a%=10;
        }
        ans.push_back(a);
    }
    for (ll i = 0; i < ans.size(); i++)
    {
        cout << ans[i] << endl;
    }
    
}
0