Skip to content

Instantly share code, notes, and snippets.

View Surgo's full-sized avatar
🛰️
Generating...

Kosei Kitahara Surgo

🛰️
Generating...
View GitHub Profile
@Surgo
Surgo / srm484_div2_level2.py
Created February 16, 2011 02:48
SRM484 - div2 - level two
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""SRM484 - div2 - level two
When cat Taro and rabbit Hanako were practicing hard for SRM 484,
they noticed an interesting property of 484.
They called it Rabbit Number.
Let S(n) be the sum of the digits of n. For example,
@Surgo
Surgo / srm485_div2_level2.py
Created February 15, 2011 13:28
SRM485 - div2 - level two
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""SRM485 - div2 - level two
A sequence of integers a[0], a[1], ..., a[N-1], where N >= 3,
is called an arithmetic progression if the difference between
any two successive terms in the sequence is a constant.
More precisely, it is an arithmetic progression
if a[i] - a[i-1] = a[i+1] - a[i] for every integer i such
@Surgo
Surgo / srm497_div2_level2.py
Created February 14, 2011 05:09
SRM497 - div2 - level two
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""SRM497 - div2 - level two
The signature of a permutation is a string that is
computed as follows: for each pair of consecutive elements
of the permutation, write down the letter 'I' (increasing)
if the second element is greater than the first one,
otherwise write down the letter 'D' (decreasing).
@Surgo
Surgo / srm490_div2_level2.py
Created February 9, 2011 01:26
SRM490 - div2 - level two
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""SRM490 - div2 - level two
A new starport has just started working. Starting from some
moment of time (call it minute 0), a new spaceship arrives
at the starport every M minutes. In other words, spaceships
arrive at the starport at minutes 0, M, 2*M, 3*M and so on.
@Surgo
Surgo / srm493_div2_level2.py
Created February 8, 2011 08:20
SRM493 - div2 - level two
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""SRM493 - div2 - level two
Romeo and his friend Strangelet are playing a game.
There are N stones in a row, all of which are black
except for the M-th one, which is white (all positions
in this problem are 1-based). The players alternate turns,
and Romeo plays first. On each turn, a player must
@Surgo
Surgo / srm494_div2_level2.py
Created February 7, 2011 06:31
SRM494 - div2 - level two
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""SRM494 - div2 - level two
Normally Mr. Grey is not a painter, but he recently had
an absolutely brilliant idea for a picture. He thinks
that once drawn, it will bring him world-wide fame.
The picture will be painted on an NxM sheet of white paper
@Surgo
Surgo / srm496_div2_level2.py
Created February 5, 2011 02:21
SRM496 - div2 - level two
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""SRM496 - div2 - level two
Manao has a bitmap H pixels high and W pixels wide.
Initially, each of the pixels is white.
Manao draws several (possibly zero) horizontal and/or
vertical strokes. A stroke is a line segment 1 pixel
thick and 1 or more pixels long. Manao only draws horizontal
@Surgo
Surgo / srm486_div2_level1.py
Created February 4, 2011 02:50
SRM486 - div2 - level one
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""SRM486 - div2 - level one
Strange abbreviations are often used to write text messages
on uncomfortable mobile devices. One particular strategy for
encoding texts composed of alphabetic characters and spaces
is the following:
@Surgo
Surgo / srm488_div2_level1.py
Created February 3, 2011 01:30
SRM488 - div2 - level one
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""SRM488 - div2 - level one
John and Brus are bored. They have n+m common friends.
The first n of them are bored and other m are not.
John chooses the j-th (1-based) friend for a talk.
If the friend is not bored, he becomes bored after the talk.
Brus does the same with the b-th (1-based) friend.
@Surgo
Surgo / srm496_div2_level1.py
Created February 1, 2011 23:30
SRM496 - div2 - level one
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""SRM496 - div2 - level one
A string X is an anagram of string Y if X can be obtained by arranging
all characters of Y in some order, without removing any characters and
without adding new characters. For example, each of the strings "baba",
"abab", "aabb" and "abba" is an anagram of "aabb", and strings "aaab",
"aab" and "aabc" are not anagrams of "aabb".