結果

問題 No.2269 eN!の整数部分の下1桁
ユーザー NAMIDAIRONAMIDAIRO
提出日時 2023-04-14 21:56:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 204 ms / 2,000 ms
コード長 877 bytes
コンパイル時間 1,289 ms
コンパイル使用メモリ 113,800 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-18 19:20:10
合計ジャッジ時間 3,162 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 4 ms
6,940 KB
testcase_17 AC 20 ms
6,940 KB
testcase_18 AC 194 ms
6,940 KB
testcase_19 AC 198 ms
6,944 KB
testcase_20 AC 204 ms
6,940 KB
testcase_21 AC 203 ms
6,940 KB
testcase_22 AC 165 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <random>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)

template<class T>
using vi = vector<T>;

template<class T>
using vii = vector<vi<T>>;

template<class T>
using viii = vector<vii<T>>;

using P = pair<ll, int>;

void chmin(ll & x, ll y) { x = min(x, y); }

double e = exp(1);

void solve() {
	ll n;
	cin >> n;
	
	if (n <= 15) {
		double te = e;
		rep(i, n) te *= i + 1;
		ll num = te;
		num %= 10;
		cout << num << endl;
		return;
	}

	ll res = 1;
	ll temp = 1;
	for (ll i = n; i > 0; i--) {
		temp *= (i % 10);
		res += temp;
		if (temp == 0) break;
	}
	cout << res % 10 << endl;
	return;
}

int main()
{
	int t;
	cin >> t;
	while (t--) solve();
	return 0;
}
0