Codeforces Beta Round #1 A,B,C

    xiaoxiao2021-03-25  62

    A. Theatre Square time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output

    Theatre Square in the capital city of Berland has a rectangular shape with the size n × m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a × a.

    What is the least number of flagstones needed to pave the Square? It's allowed to cover the surface larger than the Theatre Square, but the Square has to be covered. It's not allowed to break the flagstones. The sides of flagstones should be parallel to the sides of the Square.

    Input

    The input contains three positive integer numbers in the first line: n,  m and a (1 ≤  n, m, a ≤ 109).

    Output

    Write the needed number of flagstones.

    Examples Input 6 6 4 Output 4 题目链接:http://codeforces.com/problemset/problem/1/A 分析: 题意:给你一个矩形的常和宽,以及边长为a的正方形砖块,用砖块去铺这个矩形,允许重叠,不难,记住开__int64,否则会WA! 下面给出AC代码: 1 #include <bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 __int64 n,m,a; 6 while(scanf("%I64d%I64d%I64d",&n,&m,&a)!=EOF) 7 { 8 __int64 t=n/a; 9 __int64 s=m/a; 10 if(n%a!=0) 11 t+=1; 12 if(m%a!=0) 13 s+=1; 14 __int64 k=t*s; 15 printf("%I64d\n",k); 16 } 17 return 0; 18 } B. Spreadsheets time limit per test:10 seconds memory limit per test:64 megabytes input:standard input output:standard output

    In the popular spreadsheets systems (for example, in Excel) the following numeration of columns is used. The first column has number A, the second — number B, etc. till column 26 that is marked by Z. Then there are two-letter numbers: column 27 has number AA, 28 — AB, column 52 is marked by AZ. After ZZ there follow three-letter numbers, etc.

    The rows are marked by integer numbers starting with 1. The cell name is the concatenation of the column and the row numbers. For example, BC23 is the name for the cell that is in column 55, row 23.

    Sometimes another numeration system is used: RXCY, where X and Y are integer numbers, showing the column and the row numbers respectfully. For instance, R23C55 is the cell from the previous example.

    Your task is to write a program that reads the given sequence of cell coordinates and produce each item written according to the rules of another numeration system.

    Input

    The first line of the input contains integer number n (1 ≤ n ≤ 105), the number of coordinates in the test. Then there follow n lines, each of them contains coordinates. All the coordinates are correct, there are no cells with the column and/or the row numbers larger than 106 .

    Output

    Write n lines, each line should contain a cell coordinates in the other numeration system.

    Examples Input 2 R23C55 BC23 Output BC23R23C55 题目链接:http://codeforces.com/problemset/problem/1/B 分析:           题意:在Excel中,一个格子的位置有2种表示: 例如第23行第55列 ①R23C55 ②BC23 第一种表示方法很直观。 第二种表示方法中BC表示列。23表示行。 1-26列:A, B, C...Z 27-?列:AA, AB, AC...AZ, BA, BB, BC...ZZ ?-?:AAA...ZZZ... 跟进制的转换很类似! 输入任意一种表示,你的任务是输出另一种表示,模拟即可! 下面给出AC代码: 1 #include <bits/stdc++.h> 2 using namespace std; 3 const int maxn=1000005; 4 typedef long long ll; 5 char str[maxn]; 6 int flag; 7 void change(int n)//26进制转换 8 { 9 if(n>26) 10 change((n-1)/26); 11 printf("%c",(n-1)%26+'A'); 12 } 13 void solve1() 14 { 15 int row=0; 16 int col=0; 17 for(int i=1;i<flag;i++) 18 if(isdigit(str[i])) 19 row=row*10+str[i]-'0';//计算行 20 for(int i=flag+1;str[i];i++) 21 col=col*10+str[i]-'0';//计算列 22 change(col); 23 printf("%d\n",row); 24 } 25 void solve2() 26 { 27 int row=0; 28 int col=0; 29 for(int i=0;str[i];i++) 30 { 31 if(isupper(str[i])) 32 col=col*26+str[i]-'A'+1;//计算列 33 else row=row*10+str[i]-'0';//计算行 34 } 35 printf("R
    转载请注明原文地址: https://ju.6miu.com/read-37001.html

    最新回复(0)