Download - Soal_Simulasi_Kompetisi_ACM-ICPC.pdf
-
SOAL 1
Three Lines [Brian Dean, 2012]
Farmer John wants to monitor his N cows (1
-
SOAL 2
4Lay T3Xt 6En3Rat0r
Anda diminta membuatkan sebuah program yang bernama, "ALAY TEXT GENERATOR"
dimana memudahkan orang-orang alay seperti anda untuk memakainya. Text alay dihasilkan melalui penggantian beberapa karakter menjadi angka, dan menggunakan
seed untuk menghasilkan huruf besar yang acak.
Perubahan karakter menjadi angka berdasarkan tabel dibawah ini:
Karakter Angka
o 0
i 1
z 2
e 3
a 4
s 5
g 6
j 7
b 8
q 9
Sedangkan huruf besar dihasilkan melalui seed-seed bilangan, untuk tiap indeks- i(mulai dari 1) karakter 'a'..'z' dilakukan perhitungan yaitu jika pada i mempunyai jumlah kelipatan seed-seed
bilangan ganjil maka karakter diganti menjadi huruf besar, jika tidak maka huruf tetap huruf kecil. Untuk karakter selain 'a'..'z', karakter tidak dimanipulasi.
Spesifikasi Masukan
Masukan terdiri dari 3 baris yaitu:
Baris pertama terdiri dari 1 buah bilangan yaitu (1
-
Satu baris keluaran yaitu Text Alay yang dihasilkan.
Contoh Masukan
4
3 7 13 29
the quick brown fox jumps over the lazy dog.
Contoh Keluaran
th3 9U1cK 8R0WN f0x 7UmP5 0V3R tH3 L42y d06.
Penjelasan
Karakter 'a'..'z' yang dilakukan perubahan upper & lower case hanya pada karakter yang tidak bisa direplace dengan angka.
index karakter 3 7 13 29 jumlah status
1 t 0 genap
2 h 0 genap
3 e * 1 ganjil
4 0 genap
5 q 0 genap
6 u * 1 ganjil
7 i * 1 ganjil
8 c 0 genap
9 k * 1 ganjil
10 0 genap
11 b 0 genap
12 r * 1 ganjil
13 o * 1 ganjil
14 w * 1 ganjil
15 n * 1 ganjil
16 0 genap
17 f 0 genap
18 o * 1 ganjil
19 x 0 genap
20 0 genap
21 j * * 2 genap
22 u 0 genap
23 m 0 genap
24 p * 1 ganjil
25 s 0 genap
26 * 1 ganjil
-
27 o * 1 ganjil
28 v * 1 ganjil
29 e * 1 ganjil
30 r * 1 ganjil
31 0 genap
32 t 0 genap
33 h * 1 ganjil
34 e 0 genap
35 * 1 ganjil
36 l * 1 ganjil
37 a 0 genap
38 z 0 genap
39 y * * 2 genap
40 0 genap
41 d 0 genap
42 o * * 2 genap
43 g 0 genap
44 . 0 genap
-
SOAL 3
Balanced Cow Subsets [Neal Wu, 2012]
Farmer John's owns N cows (2
-
SOAL 4
Bookshelf [Neal Wu / Traditional, 2012]
When Farmer John isn't milking cows, stacking haybales, lining up his cows,
or building fences, he enjoys sitting down with a good book. Over the
years, he has collected N books (1
-
SOAL 5
Bookshelf [Neal Wu / Traditional, 2012]
When Farmer John isn't milking cows, stacking haybales, lining up his cows,
or building fences, he enjoys sitting down with a good book. Over the
years, he has collected N books (1
-
SOAL 6
Cows in a Row [Brian Dean, 2012]
Farmer John's N cows (1
-
SOAL 7
Doorsmeer
Pada suatu tempat cuci motor yang sederhana :)) pelanggan harus dengan sabar menunggu karena
motor hanya dapat dicuci satu per satu
Motor yang kotor harus dicuci lebih lama dari motor yang lebih bersih.
Pemilik Doorsmeer pusing untuk mengatur motor mana yg harus dicuci terlebih dahulu agar total waktu
yang ditunggu tiap pelanggan seminimal mungkin.
Sebagai contoh terdapat 3 motor untuk dicuci
dengan lama waktu cuci 10, 40, 30 menit.
penyusunan 10, 40, 30 maka pelanggan 1 menunggu 10 menit, pelanggan 2 menunggu 10+40,
pelanggan 3 menunggu 10+40+30.
maka totalnya adalah (10)+(10+40)+(10+40+30) = 140 menit.
jika penyusunan 40, 10, 30 maka total lama waktu adalah 170 menit.
Bantulah pemiliknya untuk menghitung total lama waktu yang ditunggu tiap pelanggan seminimal
mungkin.
Input
Baris pertama berisi N (1
-
SOAL 8 Empty Stalls [Brian Dean, 2013]
Farmer John's new barn consists of a huge circle of N stalls (2
-
OUTPUT FORMAT:
* Line 1: The minimum index of an unoccupied stall.
SAMPLE OUTPUT:
5
OUTPUT DETAILS:
All stalls will end up occupied except stall 5.
-
SOAL 9
Islands [Brian Dean, 2012] Problem 3:
Whenever it rains, Farmer John's field always ends up flooding. However, since the field isn't
perfectly level, it fills up with water in a non-uniform fashion, leaving a number of "islands" separated by expanses of water.
FJ's field is described as a one-dimensional landscape specified by N (1
-
The sample input matches the figure above.
OUTPUT FORMAT:
* Line 1: A single integer giving the maximum number of islands that
appear at any one point in time over the course of the
rainstorm.
SAMPLE OUTPUT (file islands.out):
4
-
SOAL 10
PECAHAN
Pada pelajaran matematika kali ini, Peter belajar menyederhanakan pecahan. Diberikan sebuah
pecahan, Peter diminta untuk menyederhanakan pecahan ke bentuk paling sederhana. Peter merasa soal ini tidaklah semudah yang dibayangkan, karena mungkin saja gurunya menjebaknya melalui soal-soal yang unik.
Spesifikasi masukan
Masukan terdiri dari beberapa kasus, input berhenti ketika End Of File. Tiap kasus terdiri dari satu baris yaitu berisi dua buah integer dipisah '/'. Dijamin bahwa masukan adalah valid (tidak
akan menimbulkan error).
Spesifikasi keluaran
Keluaran berupa beberapa baris berupa pecahan paling sederhana. NB: Pastikan program anda bisa berjalan pada kasus-kasus ekstrim!
Contoh masukan
8/2 15/6
6/8 99/100
55/55
Contoh keluaran
4 2 1/2
3/4 99/100
1
-
SOAL 11
3105. A Way To Find Primes
Time Limit: 1.0 Seconds Memory Limit: 65536K
Description
Given a integer p > 1, if p can be devided only by 1 and itself, we say that p is a prime number. For example, 31 can only be devided by 1 and 31, so 31 is a prime number; 12 can be devided by
six numbers: 1, 2, 3, 4, 6, 12, so 12 is not a prime number. The smallest ten prime number is 2, 3, 5, 7, 11, 13, 17, 19, 23, 29.
Eratosthenes was a Greek mathematician, astronomer, and geographer. He invented a method for
finding prime numbers that is still used today. This method is called Eratosthenes'Sieve. A sieve has holes in it and is used to filter out the juice. Eratosthenes's sieve filters out numbers to find the prime numbers.
Eratosthenes's sieve can be used as follows to find all prime numbers smaller than or equal to a given number n: Step1 : Put all integers between 2 and n (include 2 and n) on Eratosthenes's sieve.
Step2 : Sellect the smallest number on the sieve, suppose it is m, then m must be a prime. Step3 : Filter out all the integers which can be devided by m from Eratosthenes's sieve.
Step4 : If m * m
-
Sieve : 7, 11, 13, 17, 19
Prime bin : 2, 3, 5
Because 5 * 5 = 25 > 20, so all numbers remains on Eratosthenes's sieve are
prime, put all of them into prime bin:
Sieve :
Prime bin : 2, 3, 5, 7, 11, 13, 17, 19
Now the task is, given a number k, output the k-th smallest prime number. (You may use any way you want to solve this problem as it is correct)
Input
The first line is an integer n, the number of test cases, n cases follows. For Each test case has an single integer k (k > 1).
Output
A single integer per line, the k-th prime number. It is guaranted that the correct answer is smaller than 100000.
Sample Input
4
1
10
100
1000
Sample Output
2
29
541
7919
Hint
If you want to use an large arrays, Please define them as global variables. For example, if I want
to use an array named arr[]:
#include ...
...
...
int arr[1000000];
int main () {
......
}
-
SOAL 12 Running Laps [Brian Dean, 2012]
Bored with horse racing, Farmer John decides to investigate the feasibility
of cow racing as a sport. He sets up his N cows (1
-
SOAL 13
Silap
Peter sedang belajar angka, gurunya David sedang mengajarkan dia dengan cara yang unik. Pak
David menuliskan sebanyak n-1 angka (semua angka berbeda mulai dari 1..n dengan acak), lalu Peter disuruh untuk mencari angka yang hilang dari kumpulan angka 1..n. Peter mulai bingung cara mencarinya lalu dia meminta bantuan kalian untuk membuatkan program pencari angka
hilang.
Spesifikasi masukan
Baris pertama berisi integer (1
-
SOAL 14
Tied Down [Brian Dean, 2012]
As we all know, Bessie the cow likes nothing more than causing mischief on the farm. To keep her from causing too much trouble, Farmer John decides to tie Bessie down to a fence with a
long rope. When viewed from above, the fence consists of N posts (1
-
2 1
6 1
2 4
1 1
2 0
3 1
1 3
5 4
3 0
0 1
3 2
6 1
INPUT DETAILS:
There are two posts at (2,3) and (2,1). Bessie is at (6,1). The rope goes
from (6,1) to (2,4) to (1,1), and so on, ending finally at (6,1). The shape
of the rope is the same as in the figure above.
OUTPUT FORMAT:
* Line 1: The minimum number of posts that need to be removed in order
for Bessie to escape by running to the right.
SAMPLE OUTPUT:
1
OUTPUT DETAILS:
Removing either post 1 or post 2 will allow Bessie to escape.
-
SOAL 15
Unlocking Blocks (Silver) [Brian Dean, 2012]
A little-known fact about cows is that they love puzzles! For Bessie's birthday, Farmer John gives her an interesting mechanical puzzle for her to solve. The puzzle consists of three solid
objects, each of which is built from 1x1 unit squares glued together. Each of these objects is a "connected" shape, in the sense that you can get from one square on the object to any other square on the object by stepping north, south, east, or west, through squares on the object.
An object can be moved by repeatedly sliding it either north, south, east, or west one unit. The
goal of the puzzle is to move the objects so that they are separated -- where their bounding boxes no longer share any positive overlap with each-other. Given the shapes and locations of the three
objects, your task is to help Bessie decide what is the minimum number of individual slides required to separate the objects.
PROBLEM NAME: unlock
INPUT FORMAT:
* Line 1: Three space-separated integers: N1, N2, and N3, describing
respectively the number of unit squares making up objects 1,
2, and 3.
* Lines 2..1+N1: Each of these lines describes the (x,y) location of
the south-west corner of single square that is part of object
1. All coordinates lie in the range 0..9.
* Lines 2+N1..1+N1+N2: Each of these lines describes the (x,y)
location of the south-west corner of single square that is
part of object 2. All coordinates lie in the range 0..9.
* Lines 2+N1+N2..1+N1+N2+N3: Each of these lines describes the (x,y)
location of the south-west corner of single square that is
part of object 3. All coordinates lie in the range 0..9.
SAMPLE INPUT:
12 3 5
0 0
1 0
2 0
3 0
3 1
0 1
0 2
-
0 3
0 4
1 4
2 4
3 4
2 1
2 2
1 2
2 3
3 3
4 3
4 4
4 2
INPUT DETAILS:
Object 1 is made from 12 squares, object 2 is made from 3 squares, and
object 3 is made from 5 squares. The shapes of the objects are those in
the figure above.
OUTPUT FORMAT:
* Line 1: The minimum number of moves necessary to separate the three
objects, or -1 if the objects cannot be separated.
SAMPLE OUTPUT:
5
OUTPUT DETAILS:
If we slide object 3 to the east by one position, then slide object 2
north by one position, then slide object 1 west by three positions,
then the bounding boxes of the three objects will no longer share any
overlap in common.