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