結果
| 問題 | No.2269 eN!の整数部分の下1桁 |
| コンテスト | |
| ユーザー |
NAMIDAIRO
|
| 提出日時 | 2023-04-14 21:56:20 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 191 ms / 2,000 ms |
| コード長 | 877 bytes |
| 記録 | |
| コンパイル時間 | 982 ms |
| コンパイル使用メモリ | 109,752 KB |
| 最終ジャッジ日時 | 2025-02-12 06:37:23 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
#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;
}
NAMIDAIRO