Back Junアルゴリズム5692号:工場陣法
4677 ワード
リンク
https://www.acmicpc.net/problem/5692
sol1)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int int64_t
using namespace std;
int fact(int n){
if(n == 1) return 1;
return n *fact(n - 1);
}
int32_t main(){
fastio;
string x;
while(cin >> x){
if(x == "0") break;
int ret = 0;
for(int i = 0; i < x.size(); i++){
int c = x[i] - '0';
ret += c*fact(x.size() - i);
}
cout << ret << "\n";
}
}
Reference
この問題について(Back Junアルゴリズム5692号:工場陣法), 我々は、より多くの情報をここで見つけました https://velog.io/@inwooleeme/백준-알고리즘-5692번-팩토리얼-진법テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol