結果

問題 No.2269 eN!の整数部分の下1桁
ユーザー nagisa5101nagisa5101
提出日時 2023-04-14 22:00:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,659 bytes
コンパイル時間 5,053 ms
コンパイル使用メモリ 255,880 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-18 19:25:21
合計ジャッジ時間 6,132 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 155 ms
5,376 KB
testcase_21 AC 156 ms
5,376 KB
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace atcoder;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repll(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep2(i, n, m) for (int i = n; i < (int)(m); i++)
#define repll2(i, n, m) for (long long i = n; i < (long long)(m); i++)
#define all(v) v.begin(),v.end()
using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vvvl=vector<vvl>;
using vld=vector<ld>;
using vvld=vector<vld>;

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,1,-1};

const double PI = acos(-1);
//const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=(1LL<<60);
const int INF2=(1<<30);
//using mint=modint1000000007;
//using mint=modint998244353;

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int t;cin>>t;
    while(t--){
        ll n;cin>>n;
        if(n>=10){
            ll ans=0;
            ll now=1;
            for(ll i=n;i>=n-11;i--){
                ans+=now;
                ans%=10;
                now*=(i%10);
                now%=10;
            }
            cout<<ans%10<<endl;
        }
        else{
            ll ans=0;
            rep2(i,0,n+1){
                ll now=1;
                for(int j=n;j>=n-i+1;j--)now=(now*j);
                //cout<<i<<" "<<now<<endl;
                ans+=now;
                //if(i==n)ans+=now;
            }
            cout<<ans%10<<endl;
        }
    }
    return 0;
}
0