Tenka1 Programmer Contest/Tenka1 Programmer Beginner Contest 2018

Size: px
Start display at page:

Download "Tenka1 Programmer Contest/Tenka1 Programmer Beginner Contest 2018"

Transcription

1 Tenka1 Programmer Contest/Tenka1 Programmer Beginner Contest 2018 DEGwer 2018/10/27 For International Readers: English editorial starts on page 5. A: Measure #include <s t d i o. h> #include <s t r i n g > #include <iostream > using namespace std ; i n t main ( ) s t r i n g s ; c i n >> s ; i f ( s. s i z e ( ) == 2) cout << s << endl ; e l s e cout << s [ 2 ] << s [ 1 ] << s [ 0 ] << endl ; B: Exchange #include <s t d i o. h> using namespace std ; i n t main ( ) i n t a, b, k ; s c a n f ( %d%d%d, &a, &b, &k ) ; f o r ( i n t i = 0 ; i < k ; i ++) 1

2 i f ( i % 2 == 0) b += a / 2, a /= 2 ; e l s e a += b / 2, b /= 2 ; p r i n t f ( %d %d\n, a, b ) ; C: Align p 1,..., p N p i 1 < p i < p i+1 p i 1 > p i > p i+1 i p i p 1 p 2 p 3... p 1 p 2 p 3... (p 1 p 2 ) + (p 3 p 2 ) + (p 3 p 4 ) + (p 5 p 4 ) +... i p i ( ) p i D: Crossing k 2 1 1, 2,..., N 2 ( ) k 1 N = k(k 1)/2 1, 2,..., k(k 1)/2 1 E: Equilateral a, b, c, d b + d = a + c + d = a + b + c a + c = b = d b = d (a + c = b = d ) 45 O(max(N, M) 3 ) 2

3 1 D 2 E F: Circular A ( ) 1 1 ( K ) K A i i 3

4 i i i i ( ) i i i ( K ) i i K i i i i K ( K ) i K i i i K i i i 4

5 Tenka1 Programmer Contest/Tenka1 Programmer Beginner Contest 2018 Editorial DEGwer 2018/10/27 A: Measure #include <s t d i o. h> #include <s t r i n g > #include <iostream > using namespace std ; i n t main ( ) s t r i n g s ; c i n >> s ; i f ( s. s i z e ( ) == 2) cout << s << endl ; e l s e cout << s [ 2 ] << s [ 1 ] << s [ 0 ] << endl ; 5

6 B: Exchange #include <s t d i o. h> using namespace std ; i n t main ( ) i n t a, b, k ; s c a n f ( %d%d%d, &a, &b, &k ) ; f o r ( i n t i = 0 ; i < k ; i++) i f ( i % 2 == 0)b += a / 2, a /= 2 ; e l s e a += b / 2, b /= 2 ; p r i n t f ( %d %d\n, a, b ) ; 6

7 C: Align Suppose that after rearranging the sequence, we get p 1,..., p N. We can assume that there is no i that satisfies p i 1 < p i < p i+1 or p i 1 > p i > p i+1. If such i exists, we can move p i to the end of the sequence, and the sum of absolute differences never decreases. (If this operation results in new increasing (or decreasing) three consecutive elements at the end of the sequence, swap the last two elements again.) Thus, there are two cases: p 1 p 2 p 3... p 1 p 2 p 3... (Strictly speaking, there are some other cases like p 1 < p 2 = p 3 > p 4, but we can eliminate them with the same observation as above). Since these two cases are symmetric, let s describe the first case. We want to maximize the value (p 1 p 2 )+(p 3 p 2 )+(p 3 p 4 )+(p 5 p 4 )+... Here, we can forget about the constraint p 1 p 2 p 3... because when this condition doens t hold the value never becomes the maximum. For example, when n = 5, (p 1 p 2 ) + (p 3 p 2 ) + (p 3 p 4 ) + (p 5 p 4 ) = (+1) p 1 + ( 2) p 2 + (+2) p 3 + ( 2) p 4 + (+1) p 5. To achieve the maximum, we should assign the greatest elements to the position with the greatest coefficients. So, in the decreasing order of elements, we should assign them to positions 3, 1, 5, 2, 4 in this order. For general n, we can compute coefficients in a similar way, sort them, and assign the greatest elements to the position with the greatest coefficients. 7

8 1 Problem D D: Crossing Let k be the number of subsets we choose. From the condition in the statement, for each pair (i, j) such that 1 i < j k, there must be exactly one element that is contained in both S i and S j. Also, all elements must appear this way, because all elements are contained in exactly two sets. Thus, once we fix the value k, we can essentially uniquely determine subsets. N must be the number of pairs (i, j), thus N = k(k 1)/2. We first find k that satisfies N = k(k 1)/2 (If such k doesn t exist, there s no answer). Then, we can uniquely determine the subsets except for labelling. For example, when k = 4, There is an element contained in S 1 and S 2. Let s call it A. There is an element contained in S 1 and S 3. Let s call it B. There is an element contained in S 1 and S 4. Let s call it C. There is an element contained in S 2 and S 3. Let s call it D. There is an element contained in S 2 and S 4. Let s call it E. There is an element contained in S 3 and S 4. Let s call it F. Then we get S 1 = A, B, C, S 2 = A, D, E, and so on (and somehow assign the letters to integers between 1 and N). The following picture illustrates the case k = 6. 8

9 2 Problem E E: Equilateral There are two types of arrangements of three points on a plane: two points form a diagonal of a rectangle and the other point is inside the rectangle (like the picture on the left), or not (like the picture on the right). It s easy to see that left-type arrangement never satisfies the condition in the statement, so let s consider the right-type arrangement, and define the lengths a, b, c, d as in the picture. There lengths must satisfy b + d = a + c + d = a + b + c. Thus, we get b = d. This means that two points must be on the same diagonal (whose slope is 45 degrees). Let s fix these two points. For example, suppose that these points are (x, y) and (x + d, y + d). Then, the candidates of the coordinates of the other point are: (x d + i, y + d + i) for 0 i d. (x + d + i, y d + i) for 0 i d. With proper pre-computation (similar to prefix sums), we can count the number of existing points among these candidate coordinates in O(1). Since there are O(max(N, M) 3 ) ways to fix two points on the same diagonal, we can solve the entire problem in O(max(N, M) 3 ). Note that it s important to avoid double-countings. One possible way to do this is, in each phase, for the third point, only consider these coordinates: (x d + i, y + d + i) for 0 i < d. Then after each phase rotate the entire board by 90 degrees. After four phases, each valid triplet will be counted once. 9

10 F: Circular If all elements in given A are equal, the problem is easy, so let us assume otherwise. First, it can be seen that the region where each number occurs in A must form a contiguous segment (on the circle). Additionally, it can also be seen that the operation was performed K times, where K is the number of times 1 occurs in a row, minus 1. If there is a number that does not occur in a contiguous segment, or occurs K + 1 or more times in a row, the answer is 0. Otherwise, let us go over the numbers in A in ascending order, and for each number, determine its position in the original permutation. Let us say a number i to be existing when the given sequence A contains i. Assume we are looking at existing number i. If the number occurs just before the segment where i occurs is greater than i, the original position of i is uniquely determined (as the beginning of that segment). If the number occurs just after the segment where i occurs is greater than i, the original position of i is also uniquely determined (as K positions before the end of that segment). Note that if both numbers around the segment are greater than i and the number of times i occurs in a row is not K + 1, the answer is 0. Let us consider the remaining case, that is, both numbers around the segment where i occurs are less than i. Because of how the original positions of numbers are determined, there is no number whose original position is inside the segment where i occurs, or K or less positions before the beginning of that segment (particularly, K or less positions before the end of that segment). Thus, any position that is between 0 and K positions before the beginning of the segment where i occurs can be specified as the original position of i. Regarding the original position of non-existing i, any position that is inside the segment where numbers less than i occurs, and not among the last K positions of such segment, and not already specified as the original position of some other number, can be specified as the original position of i. Therefore, if both numbers around the segment where i occurs are less than i, or i does not exist, the number of ways to specify the original position of i does not depend on how the original positions of previous numbers are specified. We can just multiply the answer by some constant in these cases, and the problem is solved. 10

ARC 088/ABC 083. A: Libra. DEGwer 2017/12/23. #include <s t d i o. h> i n t main ( )

ARC 088/ABC 083. A: Libra. DEGwer 2017/12/23. #include <s t d i o. h> i n t main ( ) ARC 088/ABC 083 DEGwer 2017/12/23 A: Libra A, B, C, D A + B C + D #include i n t main ( ) i n t a, b, c, d ; s c a n f ( %d%d%d%d, &a, &b, &c, &d ) ; i f ( a + b > c + d ) p r i n t f (

More information

Computer Programming : C++

Computer Programming : C++ The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2003 Muath i.alnabris Computer Programming : C++ Experiment #1 Basics Contents Structure of a program

More information

Math 13 Spring 13 Liberal Arts Mathematics Chapters 19&20 Test Name

Math 13 Spring 13 Liberal Arts Mathematics Chapters 19&20 Test Name Math 13 Spring 13 Liberal Arts Mathematics Chapters 19&0 Test Name Write your answers to the following questions with thorough explanations written in complete sentences. 1. You may remember having to

More information

Log1 Contest Round 1 Theta Circles & Polygons. 4 points each. 5 points each

Log1 Contest Round 1 Theta Circles & Polygons. 4 points each. 5 points each 014 015 Log1 Contest Round 1 Theta Circles & Polygons 1 Find the area, in square inches, enclosed by a circle whose diameter is 8 inches. A rectangle has sides of length 4 and 6. Find the area enclosed

More information

1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol.

1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol. 1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol. B. Outputs to the console a floating point number f1 in scientific format

More information

CS6015 / LARP ACK : Linear Algebra and Its Applications - Gilbert Strang

CS6015 / LARP ACK : Linear Algebra and Its Applications - Gilbert Strang Solving and CS6015 / LARP 2018 ACK : Linear Algebra and Its Applications - Gilbert Strang Introduction Chapter 1 concentrated on square invertible matrices. There was one solution to Ax = b and it was

More information

Discrete Structures. Fall Homework3

Discrete Structures. Fall Homework3 Discrete Structures Fall 2015 Homework3 Chapter 5 1. Section 5.1 page 329 Problems: 3,5,7,9,11,15 3. Let P(n) be the statement that 1 2 + 2 2 + +n 2 = n(n + 1)(2n + 1)/6 for the positive integer n. a)

More information

VARIABLES & ASSIGNMENTS

VARIABLES & ASSIGNMENTS Fall 2018 CS150 - Intro to CS I 1 VARIABLES & ASSIGNMENTS Sections 2.1, 2.2, 2.3, 2.4 Fall 2018 CS150 - Intro to CS I 2 Variables Named storage location for holding data named piece of memory You need

More information

Honors Computer Science C++ Mr. Clausen Program 4A, 4B, 4C (4D, 4G)

Honors Computer Science C++ Mr. Clausen Program 4A, 4B, 4C (4D, 4G) Honors Computer Science C++ Mr. Clausen Program 4A, 4B, 4C (4D, 4G) Program 4A: Function: Comments And Output 10 points Write a program that practices comments, output, and void functions. Save the program

More information

CSCS 261 Programming Concepts Exam 2 Fall EXAM 2 VERSION 1 Fall Points. Absolutely no electronic devices may be used during this exam.

CSCS 261 Programming Concepts Exam 2 Fall EXAM 2 VERSION 1 Fall Points. Absolutely no electronic devices may be used during this exam. Name: Print legibly! Section: COMPUTER SCIENCE 261 PROGRAMMING CONCEPTS EXAM 2 VERSION 1 Fall 2014 150 Points Absolutely no electronic devices may be used during this exam. 1. No cell phones, computers,

More information

2018 AIME I Problems

2018 AIME I Problems 2018 AIME I Problems Problem 1 Let be the number of ordered pairs of integers, with and such that the polynomial x + x + can be factored into the product of two (not necessarily distinct) linear factors

More information

Chapter Four: Loops. Slides by Evan Gallagher. C++ for Everyone by Cay Horstmann Copyright 2012 by John Wiley & Sons. All rights reserved

Chapter Four: Loops. Slides by Evan Gallagher. C++ for Everyone by Cay Horstmann Copyright 2012 by John Wiley & Sons. All rights reserved Chapter Four: Loops Slides by Evan Gallagher The Three Loops in C++ C++ has these three looping statements: while for do The while Loop while (condition) { statements } The condition is some kind of test

More information

pointers + memory double x; string a; int x; main overhead int y; main overhead

pointers + memory double x; string a; int x; main overhead int y; main overhead pointers + memory computer have memory to store data. every program gets a piece of it to use as we create and use more variables, more space is allocated to a program memory int x; double x; string a;

More information

Subject: Computer Science

Subject: Computer Science Subject: Computer Science Topic: Data Types, Variables & Operators 1 Write a program to print HELLO WORLD on screen. 2 Write a program to display output using a single cout statement. 3 Write a program

More information

Finite Math - J-term Homework. Section Inverse of a Square Matrix

Finite Math - J-term Homework. Section Inverse of a Square Matrix Section.5-77, 78, 79, 80 Finite Math - J-term 017 Lecture Notes - 1/19/017 Homework Section.6-9, 1, 1, 15, 17, 18, 1, 6, 9, 3, 37, 39, 1,, 5, 6, 55 Section 5.1-9, 11, 1, 13, 1, 17, 9, 30 Section.5 - Inverse

More information

Intro to Programming & C Why Program? 1.2 Computer Systems: Hardware and Software. Why Learn to Program?

Intro to Programming & C Why Program? 1.2 Computer Systems: Hardware and Software. Why Learn to Program? Intro to Programming & C++ Unit 1 Sections 1.1-4 and 2.1-10, 2.12-13, 2.15-17 CS 1428 Spring 2019 Jill Seaman 1.1 Why Program? Computer programmable machine designed to follow instructions Program a set

More information

Inheritance, and Polymorphism.

Inheritance, and Polymorphism. Inheritance and Polymorphism by Yukong Zhang Object-oriented programming languages are the most widely used modern programming languages. They model programming based on objects which are very close to

More information

SECOND JUNIOR BALKAN OLYMPIAD IN INFORMATICS

SECOND JUNIOR BALKAN OLYMPIAD IN INFORMATICS SECOND JUNIOR BALKAN OLYMPIAD IN INFORMATICS July 8 13, 2008 Shumen, Bulgaria TASKS AND SOLUTIONS Day 1 Task 1. TOWERS OF COINS Statement Asen and Boyan are playing the following game. They choose two

More information

D-Optimal Designs. Chapter 888. Introduction. D-Optimal Design Overview

D-Optimal Designs. Chapter 888. Introduction. D-Optimal Design Overview Chapter 888 Introduction This procedure generates D-optimal designs for multi-factor experiments with both quantitative and qualitative factors. The factors can have a mixed number of levels. For example,

More information

Exercise 1.1 Hello world

Exercise 1.1 Hello world Exercise 1.1 Hello world The goal of this exercise is to verify that computer and compiler setup are functioning correctly. To verify that your setup runs fine, compile and run the hello world example

More information

Math 574 Review Exam #1

Math 574 Review Exam #1 Math 574 Review Exam 1 1. How many 8-card hands, dealt from a standard deck of 5, consist of: (a). 5 of one suit and 3 of another suit? (b). 4 each of two suits. (c). 3 of one suit, 3 of a second suit,

More information

Indiana State Math Contest Geometry

Indiana State Math Contest Geometry Indiana State Math Contest 018 Geometry This test was prepared by faculty at Indiana University - Purdue University Columbus Do not open this test booklet until you have been advised to do so by the test

More information

CSCS 261 Programming Concepts Exam 2 Fall EXAM 2 VERSION 1 Fall Points. Absolutely no electronic devices may be used during this exam.

CSCS 261 Programming Concepts Exam 2 Fall EXAM 2 VERSION 1 Fall Points. Absolutely no electronic devices may be used during this exam. Name: Print legibly! Section: COMPUTER SCIENCE 261 PROGRAMMING CONCEPTS EXAM 2 VERSION 1 Fall 2014 150 Points Absolutely no electronic devices may be used during this exam. 1. No cell phones, computers,

More information

Infinite Geometry supports the teaching of the Common Core State Standards listed below.

Infinite Geometry supports the teaching of the Common Core State Standards listed below. Infinite Geometry Kuta Software LLC Common Core Alignment Software version 2.05 Last revised July 2015 Infinite Geometry supports the teaching of the Common Core State Standards listed below. High School

More information

Chapter Four: Loops II

Chapter Four: Loops II Chapter Four: Loops II Slides by Evan Gallagher & Nikolay Kirov Chapter Goals To understand nested loops To implement programs that read and process data sets To use a computer for simulations Processing

More information

B.Stat / B.Math. Entrance Examination 2017

B.Stat / B.Math. Entrance Examination 2017 B.Stat / B.Math. Entrance Examination 017 BOOKLET NO. TEST CODE : UGA Forenoon Questions : 0 Time : hours Write your Name, Registration Number, Test Centre, Test Code and the Number of this Booklet in

More information

Combinatorics: The Fine Art of Counting

Combinatorics: The Fine Art of Counting Week Three Solutions Note: in these notes multiplication is assumed to take precedence over division, so 4!/2!2! = 4!/(2!*2!), and binomial coefficients are written horizontally: (4 2) denotes 4 choose

More information

Chapter 10 - Notes Applications of Arrays

Chapter 10 - Notes Applications of Arrays Chapter - Notes Applications of Arrays I. List Processing A. Definition: List - A set of values of the same data type. B. Lists and Arrays 1. A convenient way to store a list is in an array, probably a

More information

Problem A. Interactive Smiley Face

Problem A. Interactive Smiley Face Problem A. Interactive Smiley Face 1 second Igor likes smiley faces a lot. He wrote a program that generates really large pictures of white and black pixels with smiley faces. Depending on Igor s mood,

More information

Student number: Datenstrukturen & Algorithmen page 1

Student number: Datenstrukturen & Algorithmen page 1 Student number: Datenstrukturen & Algorithmen page 1 Problem 1. / 15 P Please note: 1) In this problem, you have to provide solutions only. You can write them right on this sheet. 2) If you use algorithms

More information

Describing and Implementing Algorithms

Describing and Implementing Algorithms Describing and Implementing Algorithms ECE2036 Lecture 1 ECE2036 Describing and Implementing Algorithms Spring 2016 1 / 19 What is an Algorithm? According to Wikipedia: An algorithm is a sequence of instructions,

More information

a. a * c - 10 = b. a % b + (a * d) + 7 =

a. a * c - 10 = b. a % b + (a * d) + 7 = Exam #2 CISC1110, MW 10:35-12:40pm Fall 2011 Name 1 Evaluate each expression according to C++ rules (8 pts) Given: Integers a = 3, b = 2, c = 5, and float d = 40 a a * c - 10 = b a % b + (a * d) + 7 =

More information

4. Structure of a C++ program

4. Structure of a C++ program 4.1 Basic Structure 4. Structure of a C++ program The best way to learn a programming language is by writing programs. Typically, the first program beginners write is a program called "Hello World", which

More information

CS222 Homework 4(Solution)

CS222 Homework 4(Solution) CS222 Homework 4(Solution) Dynamic Programming Exercises for Algorithm Design and Analysis by Li Jiang, 2018 Autumn Semester 1. Given an m n matrix of integers, you are to write a program that computes

More information

Perfect square. #include<iostream> using namespace std; int main(){ int a=1; int square; while(true){ } cout<<square<<endl; }

Perfect square. #include<iostream> using namespace std; int main(){ int a=1; int square; while(true){ } cout<<square<<endl; } Lab 3 Kaikai Bian Perfect square #include using namespace std; int main(){ int a=1; int square; while(true){ } cout

More information

LESSON 1: INTRODUCTION TO COUNTING

LESSON 1: INTRODUCTION TO COUNTING LESSON 1: INTRODUCTION TO COUNTING Counting problems usually refer to problems whose question begins with How many. Some of these problems may be very simple, others quite difficult. Throughout this course

More information

For loops, nested loops and scopes. Jordi Cortadella Department of Computer Science

For loops, nested loops and scopes. Jordi Cortadella Department of Computer Science For loops, nested loops and scopes Jordi Cortadella Department of Computer Science Outline For loops Scopes Nested loops Introduction to Programming Dept. CS, UPC 2 Calculate x y Algorithm: repeated multiplication

More information

The Ultimate Maths Vocabulary List

The Ultimate Maths Vocabulary List The Ultimate Maths Vocabulary List The 96 Words Every Pupil Needs to Know by the End of Year 6 KS1 & KS2 How to Use This Resource An essential building block in pupil s understanding of maths is their

More information

Increment and the While. Class 15

Increment and the While. Class 15 Increment and the While Class 15 Increment and Decrement Operators Increment and Decrement Increase or decrease a value by one, respectively. the most common operation in all of programming is to increment

More information

TIMSS 2011 Fourth Grade Mathematics Item Descriptions developed during the TIMSS 2011 Benchmarking

TIMSS 2011 Fourth Grade Mathematics Item Descriptions developed during the TIMSS 2011 Benchmarking TIMSS 2011 Fourth Grade Mathematics Item Descriptions developed during the TIMSS 2011 Benchmarking Items at Low International Benchmark (400) M01_05 M05_01 M07_04 M08_01 M09_01 M13_01 Solves a word problem

More information

BSc (Hons) Computer Science. with Network Security. Examinations for / Semester1

BSc (Hons) Computer Science. with Network Security. Examinations for / Semester1 BSc (Hons) Computer Science with Network Security Cohort: BCNS/15B/FT Examinations for 2015-2016 / Semester1 MODULE: PROGRAMMING CONCEPT MODULE CODE: PROG 1115C Duration: 3 Hours Instructions to Candidates:

More information

R - T (Gauss 2004) At the Gauss Store you earn 5 reward points for each $25 you spend. Stuart spent $200 and received points. Find.

R - T (Gauss 2004) At the Gauss Store you earn 5 reward points for each $25 you spend. Stuart spent $200 and received points. Find. R - T - 9 1. (Gauss 2004) t the Gauss Store you earn 5 reward points for each $25 you spend. Stuart spent $200 and received points. Find. 2. (Gauss 2009) How many numbers in list 11, 12, 13, 14, 15, 16,

More information

Lab Instructor : Jean Lai

Lab Instructor : Jean Lai Lab Instructor : Jean Lai Group related statements to perform a specific task. Structure the program (No duplicate codes!) Must be declared before used. Can be invoked (called) as any number of times.

More information

ARC093 / ABC092. wo01. min(a, B) + min(c, D) C++ #include<cstdio> #include<algorithm> using namespace std;

ARC093 / ABC092. wo01. min(a, B) + min(c, D) C++ #include<cstdio> #include<algorithm> using namespace std; ARC093 / ABC092 wo01 2018 3 25 A min(a, B) + min(c, D) C++ #include #include using namespace std; int main(){ int A, B, C, D; scanf("%d%d%d%d", &A, &B, &C, &D); printf("%d\n", min(a,

More information

Catalan Numbers. Table 1: Balanced Parentheses

Catalan Numbers. Table 1: Balanced Parentheses Catalan Numbers Tom Davis tomrdavis@earthlink.net http://www.geometer.org/mathcircles November, 00 We begin with a set of problems that will be shown to be completely equivalent. The solution to each problem

More information

Outline. For loops, nested loops and scopes. Calculate x y. For loops. Scopes. Nested loops. Algorithm: repeated multiplication x x x x

Outline. For loops, nested loops and scopes. Calculate x y. For loops. Scopes. Nested loops. Algorithm: repeated multiplication x x x x Outline For loops, nested loops and scopes For loops Scopes Jordi Cortadella Department of Computer Science Nested loops Calculate x y Algorithm: repeated multiplication x x x x y times y x i p=x i 4 3

More information

Midterm Practice Exam

Midterm Practice Exam Name: CS 410 Introduction to Software Engineering Fall 2016 Instructor: Marc Pomplun Midterm Practice Exam Duration: 75 minutes No books, no notes, and no calculators are allowed. Question 1: out of points

More information

Computer Programming. Basic Control Flow - Loops. Adapted from C++ for Everyone and Big C++ by Cay Horstmann, John Wiley & Sons

Computer Programming. Basic Control Flow - Loops. Adapted from C++ for Everyone and Big C++ by Cay Horstmann, John Wiley & Sons Computer Programming Basic Control Flow - Loops Adapted from C++ for Everyone and Big C++ by Cay Horstmann, John Wiley & Sons Objectives To learn about the three types of loops: while for do To avoid infinite

More information

PURPLE COMET MATH MEET April 2011 HIGH SCHOOL - PROBLEMS. The ratio of 3 to the positive number n is the same as the ratio of n to 192. Find n.

PURPLE COMET MATH MEET April 2011 HIGH SCHOOL - PROBLEMS. The ratio of 3 to the positive number n is the same as the ratio of n to 192. Find n. PURPLE COMET MATH MEET April 2011 HIGH SCHOOL - PROBLEMS Copyright Titu Andreescu and Jonathan Kane Problem 1 The ratio of 3 to the positive number n is the same as the ratio of n to 192. Find n. Problem

More information

Lab # 02. Basic Elements of C++ _ Part1

Lab # 02. Basic Elements of C++ _ Part1 Lab # 02 Basic Elements of C++ _ Part1 Lab Objectives: After performing this lab, the students should be able to: Become familiar with the basic components of a C++ program, including functions, special

More information

Sample tasks from: Algebra Assessments Through the Common Core (Grades 6-12)

Sample tasks from: Algebra Assessments Through the Common Core (Grades 6-12) Sample tasks from: Algebra Assessments Through the Common Core (Grades 6-12) A resource from The Charles A Dana Center at The University of Texas at Austin 2011 About the Dana Center Assessments More than

More information

COMP3121/3821/9101/ s1 Assignment 1

COMP3121/3821/9101/ s1 Assignment 1 Sample solutions to assignment 1 1. (a) Describe an O(n log n) algorithm (in the sense of the worst case performance) that, given an array S of n integers and another integer x, determines whether or not

More information

Why Is Repetition Needed?

Why Is Repetition Needed? Why Is Repetition Needed? Repetition allows efficient use of variables. It lets you process many values using a small number of variables. For example, to add five numbers: Inefficient way: Declare a variable

More information

Geometry. AIR Study Guide

Geometry. AIR Study Guide Geometry AIR Study Guide Table of Contents Topic Slide Formulas 3 5 Angles 6 Lines and Slope 7 Transformations 8 Constructions 9 10 Triangles 11 Congruency and Similarity 12 Right Triangles Only 13 Other

More information

Integrated Math I High School Math Solution West Virginia Correlation

Integrated Math I High School Math Solution West Virginia Correlation M.1.HS.1 M.1.HS.2 M.1.HS.3 Use units as a way to understand problems and to guide the solution of multi-step problems; choose and interpret units consistently in formulas; choose and interpret the scale

More information

MID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct.

MID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct. MID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct. In linked list the elements are necessarily to be contiguous In linked list the elements may locate at far positions

More information

Bulgarian Math Olympiads with a Challenge Twist

Bulgarian Math Olympiads with a Challenge Twist Bulgarian Math Olympiads with a Challenge Twist by Zvezdelina Stankova Berkeley Math Circle Beginners Group September 0, 03 Tasks throughout this session. Harder versions of problems from last time appear

More information

CSCI 111 Second Midterm Exam Fall Solutions 09.00am 09.50am, Wednesday, November 29, 2017

CSCI 111 Second Midterm Exam Fall Solutions 09.00am 09.50am, Wednesday, November 29, 2017 QUEENS COLLEGE Department of Computer Science CSCI 111 Second Midterm Exam Fall 2017 11.29.17 Solutions 09.00am 09.50am, Wednesday, November 29, 2017 Problem 1 Write the best title lines for the functions

More information

Area. Angle where two rays. Acute angle. Addend. a number to be added. an angle measuring less than 90 degrees. or line segments share an endpoint

Area. Angle where two rays. Acute angle. Addend. a number to be added. an angle measuring less than 90 degrees. or line segments share an endpoint Acute angle Addend an angle measuring less than 90 degrees a number to be added Angle where two rays or line segments share an endpoint Area the measure of space inside a figure. Area is measured in square

More information

AtCoder World Tour Finals 2019

AtCoder World Tour Finals 2019 AtCoder World Tour Finals 201 writer: rng 58 February 21st, 2018 A: Magic Suppose that the magician moved the treasure in the order y 1 y 2 y K+1. Here y i y i+1 for each i because it doesn t make sense

More information

Physics 234: Computational Physics

Physics 234: Computational Physics Physics 234: Computational Physics In-class Midterm Exam Friday, February 12, 2010 Student s Name: Fill-in-the-blank and multiple choice questions (20 points) Mark your answers on the exam sheet in blue

More information

2 + (-2) = 0. Hinojosa 7 th. Math Vocabulary Words. Unit 1. Word Definition Picture. The opposite of a number. Additive Inverse

2 + (-2) = 0. Hinojosa 7 th. Math Vocabulary Words. Unit 1. Word Definition Picture. The opposite of a number. Additive Inverse Unit 1 Word Definition Picture Additive Inverse The opposite of a number 2 + (-2) = 0 Equal Amount The same in quantity = Fraction A number in the form a/b, where b 0. Half One of two equal parts of a

More information

My First Command-Line Program

My First Command-Line Program 1. Tutorial Overview My First Command-Line Program In this tutorial, you re going to create a very simple command-line application that runs in a window. Unlike a graphical user interface application where

More information

PRACTICE MIDTERM EXAM #2

PRACTICE MIDTERM EXAM #2 This practice exam is based on the actual midterm exam from Cynthia s Spring 2014 class. It did not include a classes problem (which you should expect this quarter), and the memory/pointers problem covered

More information

Solium Capital. Darko Aleksic Dr. Peter Høyer Sean McIntyre. Darko Aleksic Sean McIntyre John Zhang. Sonny Chan Alex Fink Brett Shikaze

Solium Capital. Darko Aleksic Dr. Peter Høyer Sean McIntyre. Darko Aleksic Sean McIntyre John Zhang. Sonny Chan Alex Fink Brett Shikaze University of Calgary September 18, 008 E V E N T S P O N S O R Solium Capital C O N T E S T O R G A N I Z E R S Darko Aleksic Dr. Peter Høyer Sean McIntyre P R O B L E M A U T H O R S Darko Aleksic Sean

More information

Solutions to Problem Set 1

Solutions to Problem Set 1 CSCI-GA.3520-001 Honors Analysis of Algorithms Solutions to Problem Set 1 Problem 1 An O(n) algorithm that finds the kth integer in an array a = (a 1,..., a n ) of n distinct integers. Basic Idea Using

More information

Unit 1, Lesson 1: Moving in the Plane

Unit 1, Lesson 1: Moving in the Plane Unit 1, Lesson 1: Moving in the Plane Let s describe ways figures can move in the plane. 1.1: Which One Doesn t Belong: Diagrams Which one doesn t belong? 1.2: Triangle Square Dance m.openup.org/1/8-1-1-2

More information

Computer Programming

Computer Programming Computer Programming Dr. Deepak B Phatak Dr. Supratik Chakraborty Department of Computer Science and Engineering Session : Template Class list Dr. Deepak B. Phatak & Dr. Supratik Chakraborty, 1 Quick Recap

More information

VARIABLE, OPERATOR AND EXPRESSION [SET 1]

VARIABLE, OPERATOR AND EXPRESSION [SET 1] VARIABLE, OPERATOR AND EXPRESSION Question 1 Write a program to print HELLO WORLD on screen. Write a program to display the following output using a single cout statement. Subject Marks Mathematics 90

More information

Lab 4: Introduction to Programming

Lab 4: Introduction to Programming _ Unit 2: Programming in C++, pages 1 of 9 Department of Computer and Mathematical Sciences CS 1410 Intro to Computer Science with C++ 4 Lab 4: Introduction to Programming Objectives: The main objective

More information

CS 440 Theory of Algorithms /

CS 440 Theory of Algorithms / CS 440 Theory of Algorithms / CS 468 Algorithms in Bioinformaticsi Brute Force. Design and Analysis of Algorithms - Chapter 3 3-0 Brute Force A straightforward approach usually based on problem statement

More information

Sol. Sol. a. void remove_items_less_than(int arr[], int size, int value) #include <iostream> #include <ctime> using namespace std;

Sol. Sol. a. void remove_items_less_than(int arr[], int size, int value) #include <iostream> #include <ctime> using namespace std; r6.14 For the operations on partially filled arrays below, provide the header of a func tion. d. Remove all elements that are less than a given value. Sol a. void remove_items_less_than(int arr[], int

More information

CSCI 111 Midterm 1, version A Exam Fall Solutions 09.00am 09.50am, Tuesday, November 24, 2015

CSCI 111 Midterm 1, version A Exam Fall Solutions 09.00am 09.50am, Tuesday, November 24, 2015 QUEENS COLLEGE Department of Computer Science CSCI 111 Midterm 1, version A Exam Fall 2015 11.24.15 Solutions 09.00am 09.50am, Tuesday, November 24, 2015 Problem 1 Write the best title lines for the functions

More information

XVIII Open Cup named after E.V. Pankratiev Stage 1: Grand Prix of Romania, Sunday, September 17, 2017

XVIII Open Cup named after E.V. Pankratiev Stage 1: Grand Prix of Romania, Sunday, September 17, 2017 Problem A. Balance file: 1 second 512 mebibytes We say that a matrix A of size N N is balanced if A[i][j] + A[i + 1][j + 1] = A[i + 1][j] + A[i][j + 1] for all 1 i, j N 1. You are given a matrix A of size

More information

CS 201 (Intro. to Computing) Fall 2015 Sabancı University Sample Questions for Midterm 1

CS 201 (Intro. to Computing) Fall 2015 Sabancı University Sample Questions for Midterm 1 CS 201 (Intro. to Computing) Fall 2015 Sabancı University Sample Questions for Midterm 1 Those questions do not imply any favorite subject or question type for the questions in the actual exam Please also

More information

CHAPTER 3 BASIC INSTRUCTION OF C++

CHAPTER 3 BASIC INSTRUCTION OF C++ CHAPTER 3 BASIC INSTRUCTION OF C++ MOHD HATTA BIN HJ MOHAMED ALI Computer programming (BFC 20802) Subtopics 2 Parts of a C++ Program Classes and Objects The #include Directive Variables and Literals Identifiers

More information

Week 3: Pointers (Part 2)

Week 3: Pointers (Part 2) Advanced Programming (BETC 1353) Week 3: Pointers (Part 2) Dr. Abdul Kadir abdulkadir@utem.edu.my Learning Outcomes: Able to describe the concept of pointer expression and pointer arithmetic Able to explain

More information

Mrs. Daniel s Geometry Vocab List

Mrs. Daniel s Geometry Vocab List Mrs. Daniel s Geometry Vocab List Geometry Definition: a branch of mathematics concerned with questions of shape, size, relative position of figures, and the properties of space. Refectional Symmetry Definition:

More information

Middle School Math Course 3 Correlation of the ALEKS course Middle School Math 3 to the Illinois Assessment Framework for Grade 8

Middle School Math Course 3 Correlation of the ALEKS course Middle School Math 3 to the Illinois Assessment Framework for Grade 8 Middle School Math Course 3 Correlation of the ALEKS course Middle School Math 3 to the Illinois Assessment Framework for Grade 8 State Goal 6: Number Sense 6.8.01: 6.8.02: 6.8.03: 6.8.04: 6.8.05: = ALEKS

More information

Number/Computation. addend Any number being added. digit Any one of the ten symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, or 9

Number/Computation. addend Any number being added. digit Any one of the ten symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, or 9 14 Number/Computation addend Any number being added algorithm A step-by-step method for computing array A picture that shows a number of items arranged in rows and columns to form a rectangle associative

More information

60th ANNUAL HIGH SCHOOL HONORS MATHEMATICS CONTEST

60th ANNUAL HIGH SCHOOL HONORS MATHEMATICS CONTEST 60th ANNUAL HIGH SCHOOL HONORS MATHEMATICS CONTEST April, 017 on the campus of the University of California, San Diego PART I 5 Questions Welcome to the contest! Please do not open the exam until told

More information

Name Section: M/W or T/TH. True or False (14 Points)

Name Section: M/W or T/TH. True or False (14 Points) Name Section: M/W or T/TH True or False (14 Points) 1. (14 pts) Circle T for true and F for false: T F a) In C++, a function definition should not be nested within another function definition. T F b) Static

More information

The American University in Cairo Department of Computer Science & Engineering CSCI &09 Dr. KHALIL Exam-I Fall 2011

The American University in Cairo Department of Computer Science & Engineering CSCI &09 Dr. KHALIL Exam-I Fall 2011 The American University in Cairo Department of Computer Science & Engineering CSCI 106-07&09 Dr. KHALIL Exam-I Fall 2011 Last Name :... ID:... First Name:... Form I Section No.: EXAMINATION INSTRUCTIONS

More information

Matrix Multiplication

Matrix Multiplication Matrix Multiplication CPS343 Parallel and High Performance Computing Spring 2013 CPS343 (Parallel and HPC) Matrix Multiplication Spring 2013 1 / 32 Outline 1 Matrix operations Importance Dense and sparse

More information

Grade 9 Math Terminology

Grade 9 Math Terminology Unit 1 Basic Skills Review BEDMAS a way of remembering order of operations: Brackets, Exponents, Division, Multiplication, Addition, Subtraction Collect like terms gather all like terms and simplify as

More information

(6) The specification of a name with its type in a program. (7) Some memory that holds a value of a given type.

(6) The specification of a name with its type in a program. (7) Some memory that holds a value of a given type. CS 7A - Fall 2016 - Midterm 1 10/20/16 Write responses to questions 1 and 2 on this paper or attach additional sheets, as necessary For all subsequent problems, use separate paper Do not use a computer

More information

The transition: Each student passes half his store of candies to the right. students with an odd number of candies eat one.

The transition: Each student passes half his store of candies to the right. students with an odd number of candies eat one. Kate s problem: The students are distributed around a circular table The teacher distributes candies to all the students, so that each student has an even number of candies The transition: Each student

More information

C++ Structures Programming Workshop 2 (CSCI 1061U)

C++ Structures Programming Workshop 2 (CSCI 1061U) C++ Structures Programming Workshop 2 (CSCI 1061U) Faisal Qureshi http://faculty.uoit.ca/qureshi University of Ontario Institute of Technology C++ struct struct keyword can be used to define new data types

More information

Scientific Computing

Scientific Computing Scientific Computing Martin Lotz School of Mathematics The University of Manchester Lecture 1, September 22, 2014 Outline Course Overview Programming Basics The C++ Programming Language Outline Course

More information

Written test, 25 problems / 90 minutes

Written test, 25 problems / 90 minutes Sponsored by: UGA Math Department and UGA Math Club Written test, 5 problems / 90 minutes October 1, 017 Instructions 1. At the top of the left of side 1 of your scan-tron answer sheet, fill in your last

More information

Sample Final Exam. 1) (24 points) Show what is printed by the following segments of code (assume all appropriate header files, etc.

Sample Final Exam. 1) (24 points) Show what is printed by the following segments of code (assume all appropriate header files, etc. Name: Sample Final Exam 1) (24 points) Show what is printed by the following segments of code (assume all appropriate header files, etc. are included): a) int start = 10, end = 21; while (start < end &&

More information

Kingdom of Saudi Arabia Princes Nora bint Abdul Rahman University College of Computer Since and Information System CS242 ARRAYS

Kingdom of Saudi Arabia Princes Nora bint Abdul Rahman University College of Computer Since and Information System CS242 ARRAYS Kingdom of Saudi Arabia Princes Nora bint Abdul Rahman University College of Computer Since and Information System CS242 1 ARRAYS Arrays 2 Arrays Structures of related data items Static entity (same size

More information

HMMT February 2018 February 10, 2018

HMMT February 2018 February 10, 2018 HMMT February 2018 February 10, 2018 Combinatorics 1. Consider a 2 3 grid where each entry is one of 0, 1, and 2. For how many such grids is the sum of the numbers in every row and in every column a multiple

More information

Angles of Polygons. Essential Question What is the sum of the measures of the interior angles of a polygon?

Angles of Polygons. Essential Question What is the sum of the measures of the interior angles of a polygon? 7.1 Angles of Polygons Essential Question What is the sum of the measures of the interior angles of a polygon? The Sum of the Angle Measures of a Polygon Work with a partner. Use dynamic geometry software.

More information

Lab 2: Pointers. //declare a pointer variable ptr1 pointing to x. //change the value of x to 10 through ptr1

Lab 2: Pointers. //declare a pointer variable ptr1 pointing to x. //change the value of x to 10 through ptr1 Lab 2: Pointers 1. Goals Further understanding of pointer variables Passing parameters to functions by address (pointers) and by references Creating and using dynamic arrays Combing pointers, structures

More information

BMO Round 1 Problem 6 Solutions

BMO Round 1 Problem 6 Solutions BMO 2005 2006 Round 1 Problem 6 Solutions Joseph Myers November 2005 Introduction Problem 6 is: 6. Let T be a set of 2005 coplanar points with no three collinear. Show that, for any of the 2005 points,

More information

a) b) c) d) 4. Which graph shows a triangle and its reflection image in the y axis?

a) b) c) d) 4. Which graph shows a triangle and its reflection image in the y axis? 1. Describe in words the translation represented by (x + 6, y 3). a) 3 units to the left, 6 units up b) 3 units to the right, 6 units down c) 6 units to the right, 3 units down d) 6 units to the left,

More information

Programming 1. Lecture 6 Structured data types. Arrays

Programming 1. Lecture 6 Structured data types. Arrays Programming 1 Lecture 6 Structured data types. Arrays Objectives Understand the difference between simple and structured data types Manage the following structured data types: one-dimensional and two-dimensional

More information

CIS220 In Class/Lab 1: Due Sunday night at midnight. Submit all files through Canvas (25 pts)

CIS220 In Class/Lab 1: Due Sunday night at midnight. Submit all files through Canvas (25 pts) CIS220 In Class/Lab 1: Due Sunday night at midnight. Submit all files through Canvas (25 pts) Problem 0: Install Eclipse + CDT (or, as an alternative, Netbeans). Follow the instructions on my web site.

More information

Unit 3: Triangles and Polygons

Unit 3: Triangles and Polygons Unit 3: Triangles and Polygons Background for Standard G.CO.9: Prove theorems about triangles. Objective: By the end of class, I should Example 1: Trapezoid on the coordinate plane below has the following

More information