[PYTHON] Codeforces Beta Round # 1

Yes. I haven't made any progress as a flutter, but I started asking questions in the past. http://codeforces.com/contest/1

A problem Roughly There is a theater garden in Berland, with an area of n * m. Spread the garden with the minimum number of stones a * a.

If you imagine filling it from the origin O, you should not be able to put stones at the edges, but it's not allowed to break the flagstones. As far as many people have seen, they used a common method, so can the standard problem and formula hold? .. ..

((n+a-1)/a)*((m+a-1)/a)
((Vertical in the garden+stone-1)/stone)*((Next to the garden+stone-1)/stone)

Since the stone is square this time, the vertical and horizontal directions do not change, but the method of applying the formula for rectangular stone is currently unknown.

a.py


(n,m,a)=map(int,raw_input().split())
#if n%a != 0: n+= n%a
#if m%a != 0: m+= m%a
print ((n+a-1)/a)*((m+a-1)/a)

B problem Roughly Excel-like spreadsheet There are two types of n-line input given. BC23 BC is column, 23 is row R23C55 R is Row, C is column

602523 Its Last Day referred to the solution.

b.py


#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import timeit
import time
import sys
import io
import re
import math

n=int(raw_input())
for i in range(n):
    m=raw_input()
#Check if the input is R number C number
#Originally match=Although it was written in, I avoided it because it conflicts with the match statement when it is reused in the future.
    chk=re.search(r'R(\d+)C(\d+)',m)
    if chk:
#Can you retrieve the first and second places you are searching for? ?? Great
        x=int(chk.group(2))
        res=''
        while x:
#Review the built-in function ord
            res=chr(ord('A')+(x-1)%26)+res
            x=(x-1)/26
#No need to process anything if the row can be extracted numerically
        print (res+chk.group(1))
    else:
#Here too, search is prepared to extract only non-numeric values and numerical values.
        t=re.search(r'(\D+)(\d+)',m)
        x=0
        for letter in t.group(1):
            x=x*26+(ord(letter)-ord('A')+1)
#No need to process if you take the line
#The column is also ord here()To
        print ('R%dC%d' % (int(t.group(2)), x))

C problem I don't know There was a person who explained the problem sentence with a Japanese translation. http://d.hatena.ne.jp/kyuridenamida/20120124/1327336975

A little here on hold

Recommended Posts

Codeforces Beta Round # 13
Codeforces Beta Round # 1
Codeforces Beta Round # 2
Educational Codeforces Round 87
Codeforces Round # 643 (Div. 2) Review
Codeforces Round # 679 (Div. 2) Review (10/25)
Codeforces Round # 657 (Div. 2) Review
Codeforces Round # 658 (Div. 2) Bacha Review (7/29)
Codeforces Round # 654 (Div. 2) Bacha Review (8/18)
Codeforces Round # 594 (Div. 2) Bacha Review (10/29)
Educational Codeforces Round 93 Bacha Review (8/17)
Codeforces Round # 609 (Div. 2) Bacha Review (10/8)
Educational Codeforces Round 94 Bacha Review (9/3)
Educational Codeforces Round 91 Bacha Review (7/28)
Codeforces Round # 597 (Div. 2) Bacha Review (10/27)
Codeforces Round # 666 (Div. 2) Bacha Review (9/2)
Codeforces Round # 651 (Div. 2) Bacha Review (8/20)
Codeforces Round # 659 (Div. 2) Bacha Review (8/5)
Codeforces Round # 610 (Div. 2) Bacha Review (10/5)
Codeforces Round # 479 (Div. 3) Bacha Review (9/25)
Codeforces Round # 603 (Div. 2) Bacha Review (10/15)
Educational Codeforces Round 88 Bacha Review (8/4)
Codeforces Round # 600 (Div. 2) Bacha Review (10/21)
Codeforces Round # 481 (Div. 3) Bacha Review (9/24)
Codeforces Round # 639 (Div. 2) Bacha Review (9/4)
Codeforces Round # 612 (Div. 2) Bacha Review (10/2)
Codeforces Round # 521 (Div. 3) Bacha Review (10/9)
Educational Codeforces Round 86 Bacha Review (9/17)
Codeforces Round # 673 (Div. 2) Bacha Review (10/22)
Codeforces Round # 606 (Div. 3) Bacha Review (10/13)
Codeforces Round # 613 (Div. 2) Bacha Review (10/1)
Codeforces Round # 665 (Div. 2) Bacha Review (8/23)
Codeforces Round # 592 (Div. 2) Bacha Review (11/03)
Codeforces Round # 662 (Div. 2) Bacha Review (8/8)
Codeforces Round # 618 (Div. 2) Bacha Review (9/26)
Codeforces Round # 648 (Div. 2) Bacha Review (9/5)
Codeforces Round # 676 (Div. 2) Bacha Review (10/31)
Codeforces Round # 675 (Div. 2) Bacha Review (10/30)
Codeforces Round # 486 (Div. 3) Bacha Review (9/23)
Educational Codeforces Round 89 Bacha Review (9/8)
Codeforces Round # 669 (Div. 2) Bacha Review (9/9)
Codeforces Round # 672 (Div. 2) Bacha Review (10/16)
Codeforces Round # 638 (Div. 2) Bacha Review (9/16)
Codeforces Round # 663 (Div. 2) Bacha Review (8/13)
Educational Codeforces Round 92 Bacha Review (7/30)
Codeforces Round # 668 (Div. 2) Bacha Review (9/7)
Codeforces Round # 626 B. Count Subrectangles
Codeforces Round # 663 (Div. 2) Bacha Review (8/16)
Codeforces Round # 609 (Div. 2) Bacha Review (10/6)
Codeforces Round # 645 (Div. 2) Bacha Review (9/10)
Educational Codeforces Round 90 Bacha Review (8/19)
Codeforces Round # 664 (Div. 2) Bacha Review (8/13)
Codeforces Round # 660 (Div. 2) Bacha Review (8/4)
Codeforces Round # 609 (Div. 2) (up to B)