# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
70647 | 2018-08-23T08:04:36 Z | 김세빈(#2186) | Fibonacci representations (CEOI18_fib) | C++11 | 4000 ms | 1336 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef __int128 lll; const ll mod = 1e9 + 7; lll F[1010]; vector <ll> A; ll n; ll calc(vector <ll> &V) { ll i, k, p1, p2, _p1, _p2; p1 = 1, p2 = 0; for(i=V.size()-2; i>=0; i--){ k = V[i] - V[i + 1]; _p1 = (p1 + p2) % mod; if(k & 1) _p2 = (k / 2) * (p1 + p2) % mod; else _p2 = ((k / 2 - 1) * (p1 + p2) + p2) % mod; p1 = _p1, p2 = _p2; } return (p1 + p2) % mod; } ll f(lll v) { vector <ll> V; ll i; for(i=120; i>=1; i--){ if(F[i] <= v){ v -= F[i]; V.push_back(i); } } V.push_back(0); return calc(V); } int main() { ll i, j, a; lll s; F[0] = F[1] = 1; for(i=2; i<=120; i++){ F[i] = F[i - 1] + F[i - 2]; } scanf("%lld", &n); s = 0; A.push_back(0); for(i=1; i<=n; i++){ scanf("%lld", &a); if(a <= 120) s += F[a]; A.push_back(a); sort(A.rbegin(), A.rend()); for(j=0; j<A.size()-2; j++) if(A[j] <= A[j + 1] + 1) break; if(j == A.size() - 2) printf("%lld\n", calc(A)); else printf("%lld\n", f(s)); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 540 KB | Output is correct |
4 | Correct | 2 ms | 564 KB | Output is correct |
5 | Correct | 3 ms | 564 KB | Output is correct |
6 | Correct | 3 ms | 564 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 540 KB | Output is correct |
4 | Correct | 2 ms | 564 KB | Output is correct |
5 | Correct | 3 ms | 564 KB | Output is correct |
6 | Correct | 3 ms | 564 KB | Output is correct |
7 | Correct | 3 ms | 572 KB | Output is correct |
8 | Correct | 3 ms | 748 KB | Output is correct |
9 | Correct | 2 ms | 760 KB | Output is correct |
10 | Correct | 2 ms | 760 KB | Output is correct |
11 | Correct | 3 ms | 760 KB | Output is correct |
12 | Correct | 3 ms | 760 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 760 KB | Output is correct |
2 | Correct | 3 ms | 760 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 540 KB | Output is correct |
4 | Correct | 2 ms | 564 KB | Output is correct |
5 | Correct | 3 ms | 564 KB | Output is correct |
6 | Correct | 3 ms | 564 KB | Output is correct |
7 | Correct | 3 ms | 572 KB | Output is correct |
8 | Correct | 3 ms | 748 KB | Output is correct |
9 | Correct | 2 ms | 760 KB | Output is correct |
10 | Correct | 2 ms | 760 KB | Output is correct |
11 | Correct | 3 ms | 760 KB | Output is correct |
12 | Correct | 3 ms | 760 KB | Output is correct |
13 | Correct | 3 ms | 760 KB | Output is correct |
14 | Correct | 3 ms | 760 KB | Output is correct |
15 | Correct | 2 ms | 760 KB | Output is correct |
16 | Correct | 3 ms | 760 KB | Output is correct |
17 | Correct | 3 ms | 760 KB | Output is correct |
18 | Correct | 3 ms | 760 KB | Output is correct |
19 | Incorrect | 3 ms | 760 KB | Output isn't correct |
20 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 760 KB | Output is correct |
2 | Execution timed out | 4080 ms | 1336 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 540 KB | Output is correct |
4 | Correct | 2 ms | 564 KB | Output is correct |
5 | Correct | 3 ms | 564 KB | Output is correct |
6 | Correct | 3 ms | 564 KB | Output is correct |
7 | Correct | 3 ms | 572 KB | Output is correct |
8 | Correct | 3 ms | 748 KB | Output is correct |
9 | Correct | 2 ms | 760 KB | Output is correct |
10 | Correct | 2 ms | 760 KB | Output is correct |
11 | Correct | 3 ms | 760 KB | Output is correct |
12 | Correct | 3 ms | 760 KB | Output is correct |
13 | Correct | 3 ms | 760 KB | Output is correct |
14 | Correct | 3 ms | 760 KB | Output is correct |
15 | Correct | 2 ms | 760 KB | Output is correct |
16 | Correct | 3 ms | 760 KB | Output is correct |
17 | Correct | 3 ms | 760 KB | Output is correct |
18 | Correct | 3 ms | 760 KB | Output is correct |
19 | Incorrect | 3 ms | 760 KB | Output isn't correct |
20 | Halted | 0 ms | 0 KB | - |