CF考古活动

Codeforces Beta Round #1 

http://codeforces.com/contest/1

A.测试用水题,呵呵。给三个数nma,求ceil(n/a)*ceil(m/a)。 长整型。

 1 #include <iostream>
 2 #include <bits/stdc++.h>
 3 using namespace std;
 4 
 5 int main()
 6 {
 7     int n,m,a;
 8     cin >> n >> m >> a;
 9     long long num=(long long)ceil(1.0*n/a)*(long long)ceil(1.0*m/a);
10     cout << num << endl;
11     return 0;
12 }
View Code

B.EXCEL,细节题。变形26进制转换。

 1 #include <iostream>
 2 #include <bits/stdc++.h>
 3 using namespace std;
 4 
 5 int main()
 6 {
 7     int n;
 8     string x;
 9     cin >> n;
10     for(int i=0;i<n;i++){
11         cin >> x;
12         int way=0;
13         if(x[0]!='R'){
14             way=1;
15         }
16         else{
17             if(x[1]>'9'||x[1]<'0'){
18                 way=1;
19             }
20             else{
21                 for(int j=2;x[j];j++){
22                     if(x[j]>'9'||x[j]<'0'){
23                         way=2;
24                         break;
25                     }
26                 }
27                 if(!way)way=1;
28             }
29         }
30 
31         if(way==1){
32             int col=0,row=0;
33             for(int j=0;x[j];j++){
34                 if(x[j]>='0'&&x[j]<='9')
35                     row=row*10+x[j]-'0';
36                 else
37                     col=col*26+x[j]-'A'+1;
38             }
39             printf("R%dC%d
",row,col);
40         }
41         else {
42             int col=0,row=0;
43             int j;
44             for(j=1;x[j];j++){
45                 if(x[j]=='C')break;
46                 row=row*10+x[j]-'0';
47             }
48             for(j++;x[j];j++){
49                 col=col*10+x[j]-'0';
50             }
51             stack<int> st;
52             while(col>0){
53                 col--;
54                 st.push(col%26);
55                 col/=26;
56             }
57             while(st.size()){
58                 printf("%c",st.top()+'A');
59                 st.pop();
60             }
61             printf("%d
",row);
62         }
63 
64     }
65     return 0;
66 }
View Code
原文地址:https://www.cnblogs.com/bestefforts/p/9090326.html