Submission #155096
Source Code Expand
#include <iostream> #include <vector> #include <algorithm> #define loop(n, i) for(int i=0;i<n;i++) #define loop_from_to(from, to, i) for(int i=from;i<=to;i++) #define repeat(n) for(int i__=0;i__<n;i__++) #define multi_cin(n, array) loop(n,i){cin>>array[i];} #define assign_if_smaller(var, val) if(var>val)var=val; #define assign_if_larger(var, val) if(var<val)var=val; #define each(itr, c) for(__typeof((c).begin()) itr=(c).begin(); itr!=(c).end(); itr++) #define r_each(itr, c) for(__typeof((c).rbegin()) itr=(c).rbegin(); itr!=(c).rend(); itr++) using namespace std; const int MAX = 10000001; const int MOD = 10007; int m[MAX]; int calc(int n) { if(m[n-1] == -1) m[n-1] = (calc(n-1) + calc(n-2) + calc(n-3)) % MOD; return m[n-1]; } int main(int argc, char const* argv[]) { fill(m, m+MAX, -1); m[0] = 0; m[1] = 0; m[2] = 1; int n; cin >> n; cout << calc(n) << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - トリボナッチ数列 |
User | na_o_s |
Language | C++11 (GCC 4.8.1) |
Score | 100 |
Code Size | 939 Byte |
Status | AC |
Exec Time | 155 ms |
Memory | 71084 KB |
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 100 / 100 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | test_1.txt, test_1000000.txt, test_1002.txt, test_104.txt, test_107843.txt, test_10980.txt, test_1212.txt, test_1238.txt, test_13194.txt, test_14.txt, test_16.txt, test_2.txt, test_210782.txt, test_21694.txt, test_243.txt, test_24916.txt, test_278.txt, test_3.txt, test_31.txt, test_32.txt, test_42.txt, test_5555.txt, test_567914.txt, test_61868.txt, test_765671.txt, test_8195.txt, test_8353.txt, test_9.txt, test_9625.txt, test_97.txt, test_998.txt, test_999998.txt, test_999999.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 83 ms | 39832 KB |
sample_02.txt | AC | 82 ms | 39848 KB |
sample_03.txt | AC | 91 ms | 42908 KB |
test_1.txt | AC | 82 ms | 39836 KB |
test_1000000.txt | AC | 155 ms | 71076 KB |
test_1002.txt | AC | 79 ms | 39848 KB |
test_104.txt | AC | 82 ms | 39840 KB |
test_107843.txt | AC | 91 ms | 43176 KB |
test_10980.txt | AC | 83 ms | 40108 KB |
test_1212.txt | AC | 82 ms | 39852 KB |
test_1238.txt | AC | 84 ms | 39844 KB |
test_13194.txt | AC | 84 ms | 40236 KB |
test_14.txt | AC | 83 ms | 39848 KB |
test_16.txt | AC | 84 ms | 39792 KB |
test_2.txt | AC | 86 ms | 39788 KB |
test_210782.txt | AC | 96 ms | 46364 KB |
test_21694.txt | AC | 84 ms | 40480 KB |
test_243.txt | AC | 84 ms | 39852 KB |
test_24916.txt | AC | 82 ms | 40604 KB |
test_278.txt | AC | 82 ms | 39844 KB |
test_3.txt | AC | 82 ms | 39852 KB |
test_31.txt | AC | 83 ms | 39852 KB |
test_32.txt | AC | 83 ms | 39844 KB |
test_42.txt | AC | 84 ms | 39848 KB |
test_5555.txt | AC | 82 ms | 39976 KB |
test_567914.txt | AC | 121 ms | 57508 KB |
test_61868.txt | AC | 88 ms | 41716 KB |
test_765671.txt | AC | 136 ms | 63780 KB |
test_8195.txt | AC | 83 ms | 40220 KB |
test_8353.txt | AC | 83 ms | 40096 KB |
test_9.txt | AC | 81 ms | 39796 KB |
test_9625.txt | AC | 82 ms | 40096 KB |
test_97.txt | AC | 84 ms | 39796 KB |
test_998.txt | AC | 83 ms | 39844 KB |
test_999998.txt | AC | 150 ms | 71024 KB |
test_999999.txt | AC | 155 ms | 71084 KB |