Codeforces综合训练

Codeforces综合训练

为什么要训练

水平太低,天天比赛爆炸,原来OI保持的水平和做的题目内容已经不适合当下的ACM了

训练内容

Codeforces Beta Round #1

A

简单题,不写题解了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

long long n,m,a,flaga,flagb;

int main(){
scanf("%I64d %I64d %I64d",&n,&m,&a);
if(n%a)flaga=1;
if(m%a)flagb=1;
printf("%I64d\n",(n/a+flaga)*(m/a+flagb));
return 0;
}

B

字符串处理,本质上是个进制转换,要注意一些细节

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
using namespace std;

const int N=100005;

int test;
char str[N];

int main(){
freopen("B.in","r",stdin);
freopen("B.out","w",stdout);
scanf("%d",&test);
while(test--){
scanf("%s",str+1);
int len=strlen(str+1),flag=1;
for(register int i=2;i<=len;i++){
if(str[i-1]>='0' && str[i-1]<='9' && str[i]>='A' && str[i]<='Z')flag++;
}
int row=0,col=0;
if(flag==1){
for(register int i=1;i<=len;i++){
if('A'<=str[i] && str[i]<='Z')col=col*26+str[i]-'A'+1;
if('0'<=str[i] && str[i]<='9')row=row*10+str[i]-'0';
}
printf("R%dC%d\n",row,col);
}
else {
int fa=0;
for(register int i=2;i<=len;i++){
if(str[i]=='C')fa=1;
else {
if(fa)col=col*10+str[i]-'0';
else row=row*10+str[i]-'0';
}
}
stack<int> Stk;
while(col){
Stk.push((col-1)%26+1);
col=(col-1)/26;
}
while(!Stk.empty()){putchar('A'-1+Stk.top());Stk.pop();}
printf("%d\n",row);
}
}
return 0;
}

C


Codeforces综合训练
http://hexo.init-new-world.com/Codeforces-zong-he-xun-lian
Author
John Doe
Posted on
October 22, 2019
Licensed under