Submission #24010609
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define endl "\n"
#define rep(i, n) for (int i = 0; i < n; i++)
ll fact(ll val)
{
ll res=1;
for(int i=1;i<=val;i++)
{
res*=i;
}
return res;
}
void solve()
{
ll n;
cin>>n;
ll count=0;
vector<ll> v(10);
for(int i=1;i<=10;i++)
{
v[i-1]=fact(i);
}
for(int i=9;i>=0;i--)
{
if(v[i]<=n)
{
ll q=n/v[i];
n-=v[i]*q;
count+=q;
}
}
cout<<count<<endl;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.in", "r", stdin);
freopen("output.in", "w", stdout);
#endif
int t;
t=1;
while (t--)
{
solve();
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Factorial Yen Coin |
| User | EramallaAravind |
| Language | C++ (GCC 9.2.1) |
| Score | 200 |
| Code Size | 816 Byte |
| Status | AC |
| Exec Time | 10 ms |
| Memory | 3608 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 200 / 200 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample_00.txt, sample_01.txt, sample_02.txt |
| All | max_00.txt, min_00.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, sample_00.txt, sample_01.txt, sample_02.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| max_00.txt | AC | 10 ms | 3604 KiB |
| min_00.txt | AC | 2 ms | 3440 KiB |
| random_00.txt | AC | 2 ms | 3420 KiB |
| random_01.txt | AC | 2 ms | 3552 KiB |
| random_02.txt | AC | 2 ms | 3504 KiB |
| random_03.txt | AC | 3 ms | 3580 KiB |
| random_04.txt | AC | 7 ms | 3476 KiB |
| sample_00.txt | AC | 2 ms | 3428 KiB |
| sample_01.txt | AC | 6 ms | 3504 KiB |
| sample_02.txt | AC | 2 ms | 3608 KiB |