Codeforces Beta Round #1
来源:互联网 发布:vim可以用在windows吗 编辑:程序博客网 时间:2024/05/16 18:27
A. Theatre Square
题目大意:给定n*m的正方形广场和a*a的砖,求最少要用多少砖才给覆盖整个广场。
输入: n,m 和 a( 1 <= n, m, a <= 10^9)
输出:最少砖的数量
题解:算一下,覆盖一行要多少块砖,要覆盖多少行,不过要注意这边要用long long 。
代码:
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <iostream>using namespace std;long long work(long long n, long long m, long long k){ long long a = (n+k-1)/k; long long b = (m+k-1)/k; return a*b;}int main(){ long long n, m, a; cin >> n >> m >> a; long long ans1 = work(n,m,a); cout << ans1 << endl; return 0;}
B. Spreadsheets
题目大意:Excel有两种表示行列的方式:
1、RxCy即行为x,列为y。
2、像AB1这样的形式。把A..Z当作1..26行,AA为27行,以此类推。
输入:n表示有n行。以下n行,每行一个行列的一种坐标
输出:对每一种坐标输入,输出另一种坐标
题解:主要的难题是把字母所表示的数,转为正常的10进制数。我们假设字母为 An An-1 An-2...A1。那么这个表示的数字与AAA...A(n个A)的距离为
dis = (An - 'A')*26^(n- 1)+ (An-1 - 'A' )*26^(n-2)..+(A1-'A')*1,
把这个数加上AAA...A(n个A)即我们要求的数。
nA = 26^(n-1)+26^(n-2)...+26number = (An - 'A' + 1)*26^(n- 1)+ (An-1 - 'A' + 1)*26^(n-2)..+(A1 - 'A' + 1)*1。
那么要把数字转为字母序列也很简单即:A1 = (number - 1) % 26 + 'A'以此类推。
代码:
//written by nothi#include <stdio.h>#include <stdlib.h>#include <string.h>const int maxn = 1000;int a, b;char s[maxn];char R[maxn];char C[maxn];int final[maxn];void change_26(int num){ int now = 0; while(num > 0){ final[now++] = ((num-1) % 26) + 'A'; num = (num-1)/ 26; } for(int i = now - 1; i >= 0; i--)putchar(final[i]);}int main(){ int n, num; scanf("%d\n",&n); while(n--){gets(s);num = sscanf(s,"%[^0123456789]%d%[^0123456789]%d",R,&a,C,&b);if(num == 4){ change_26(b); printf("%d\n",a);}else{ int len = strlen(R); int num = 0, base = 1; for(int i = len - 1; i >= 0; i--){ num += (R[i]-'A'+1)*base; base *= 26; } printf("R%dC%d\n",a,num);} } return 0;}
C. Ancient Berland Circus(暂没做)
ght:21px; text-align:center">
- Codeforces Beta Round #1
- Codeforces Beta Round #1
- Codeforces Beta Round #1
- Codeforces Beta Round #1
- Codeforces Beta Round #1
- Codeforces Beta Round #1
- Codeforces Beta Round #1
- Codeforces Beta Round #1
- Codeforces Beta Round #1
- Codeforces Beta Round #1 练习
- Codeforces Beta Round #1 ABC
- Codeforces Beta Round #1(A,B)
- Codeforces Beta Round #83 (Div. 1 Only)
- Codeforces Beta Round #1 A B C
- Codeforces Beta Round #1 A题
- Codeforces Beta Round #1 A B C
- Codeforces Beta Round #1 A - Theatre Square
- Codeforces Beta Round #1 A. Theatre Square
- 白话算法之快速排序
- 企业家们应该从李彦宏的狼性文化学什么?
- 什么是自由流程
- C/C++开发语言系列之3--static 类成员
- 国内免费(开源)CMS系统大全
- Codeforces Beta Round #1
- 企业基础架构AD管理的两个低级错误
- 【Windows 核心编程】Windows 核心编程 -- 错误处理
- struts2中ValueStack和Stack Context二者的区别
- voip 视频 通信中的三种 丢包 恢复 技术
- Webservice soap wsdl区别之个人见解
- 全排列打印(二)
- C语言数据类型占字节数
- Linux--Shell编程-case,for,while,until