From 17c72df16d9053f5e00092108090c1b0e81752d0 Mon Sep 17 00:00:00 2001 From: Jacob Magnuson Date: Sat, 18 Feb 2017 02:03:31 +0000 Subject: [PATCH] add things-dont-add-up --- things-dont-add-up/description.md | 6 +++--- things-dont-add-up/generator.py | 19 ++++++++++++++++- things-dont-add-up/grader.java | 35 +++++++++++++++++++++++++++++++ things-dont-add-up/grader.py | 2 +- things-dont-add-up/problem.yml | 6 +++++- 5 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 things-dont-add-up/grader.java diff --git a/things-dont-add-up/description.md b/things-dont-add-up/description.md index 00b2589..5b23de1 100644 --- a/things-dont-add-up/description.md +++ b/things-dont-add-up/description.md @@ -11,11 +11,11 @@ The first line contains three integers `A B N`. The second line contains a serie #### Input Constraints -`0 < N < 16` +`0 < N <= 16` -`0 < A < B < 10000000` +`0 < A < B <= 10000000` -`0 < d_i < 10000000` +`0 < d_i <= 10000000` #### Sample Input diff --git a/things-dont-add-up/generator.py b/things-dont-add-up/generator.py index f87f5c1..398325e 100644 --- a/things-dont-add-up/generator.py +++ b/things-dont-add-up/generator.py @@ -1 +1,18 @@ -# TODO \ No newline at end of file +N = input() + +if N == 0: + print '8 15 3\n4 9 11' +elif N == 1: + print '50 55 3\n7 24 33' +elif N == 2: + print '123 456 3\n5 7 11' +elif N == 3: + print '1 10000000 16\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16' +else: + import random as r + r.seed(N) + lo = r.randint(1, 5000000) + hi = r.randint(lo + 1, 10000000) + N = 16 + nugs = [str(r.randint(1, 10000000)) for i in range(16)] + print '%d %d 16\n%s' % (lo, hi, ' '.join(nugs)) \ No newline at end of file diff --git a/things-dont-add-up/grader.java b/things-dont-add-up/grader.java new file mode 100644 index 0000000..fbae6c1 --- /dev/null +++ b/things-dont-add-up/grader.java @@ -0,0 +1,35 @@ +import java.util.Scanner; + +public class grader { + + public static void main(String[] args) { + + + Scanner s = new Scanner(System.in); + + int A = s.nextInt(), B = s.nextInt(), N = s.nextInt(), count = 0; + int[] nugs = new int[N]; + for(int i = 0; i < N; i++) + nugs[i] = s.nextInt(); + + + // 1 10000000 16 788069 788246 419404 186300 847360 357398 969137 457317 770314 238904 904353 340869 513632 232159 549739 279898 + boolean[] poss = new boolean[B + 1]; + poss[0] = true; + for(int i = 0; i < A; i++) + if(poss[i]) + for(int n : nugs) + if(i + n <= B) + poss[i + n] = true; + for(int i = A; i <= B; i++) + if(poss[i]) { + for(int n : nugs) + if(i + n <= B) + poss[i + n] = true; + } + else count++; + System.out.println(count); + + } + +} \ No newline at end of file diff --git a/things-dont-add-up/grader.py b/things-dont-add-up/grader.py index f87f5c1..d3c6fc3 100644 --- a/things-dont-add-up/grader.py +++ b/things-dont-add-up/grader.py @@ -1 +1 @@ -# TODO \ No newline at end of file +# done in grader.java diff --git a/things-dont-add-up/problem.yml b/things-dont-add-up/problem.yml index 56794b6..e3cb42a 100644 --- a/things-dont-add-up/problem.yml +++ b/things-dont-add-up/problem.yml @@ -3,4 +3,8 @@ title: Things Don't Add Up category: Programming autogen: false programming: true -value: 280 \ No newline at end of file +value: 210 + +test_cases: 15 +time_limit: 1000 +memory_limit: 256000 \ No newline at end of file