QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#432839 | #6712. Sum of Factorials | surenjamts# | WA | 3ms | 3556kb | C++14 | 689b | 2024-06-07 18:39:45 | 2024-06-07 18:39:45 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e6 + 5;
bool ans[N+5];
void solve() {
int n;
cin >> n;
if(n == -1) return;
if(ans[n]) cout << "Yes\n";
else cout << "No\n";
solve();
}
signed main(){
long long fact[20];
fact[0] = 1;
for (int i = 1; i<=11; i++){
fact[i] = fact[i-1] * i;
}
ans[0] = true;
ans[1] = true;
for(int k = 1; k<=11; k++){
vector<int> temp;
for(int i = 0; i<=N; i++){
if(ans[i]) {
if(i + fact[k] > N) continue;
temp.push_back(i + fact[k]);
}
}
for(auto it : temp) ans[it] = true;
}
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 3556kb
input:
9 -1
output:
Yes
result:
wrong answer 1st lines differ - expected: 'YES', found: 'Yes'