Codeforces Beta Round #1

http://codeforces.com/contest/1

A

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 const long long MOD=1e9+7;
 4 
 5 int main(){
 6     long long n,m,a;
 7     cin>>n>>m>>a;
 8     long long aa=n/a;
 9     if(n%a) aa++;
10     long long bb=m/a;
11     if(m%a) bb++;
12     cout<<aa*bb<<endl;
13 }
View Code

B

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 void ss(int col){
 4     if(col>26) ss((col-1)/26);
 5     cout<<char((col-1)%26+'A');
 6 }
 7 
 8 int main(){
 9     int n;
10     string str;
11     cin>>n;
12     while(n--){
13         cin>>str;
14         int flag=-1;
15         if(str[0]=='R'&&str[1]>='0'&&str[1]<='9'){
16             int i;
17             for(i=1;i<str.length();i++){
18                 if(str[i]=='C'){
19                     flag=i;
20                     break;
21                 }
22             }
23         }
24         if(flag==-1){
25             int row=0,col=0;
26             for(int i=0;i<str.length();i++){
27                 if(str[i]>='A'&&str[i]<='Z'){
28                     row=row*26+str[i]-'A'+1;
29                 }
30                 else{
31                     col=col*10+str[i]-'0'; 
32                 }
33             }
34             cout<<"R"<<col<<"C"<<row<<endl;
35         }
36         else{
37             int row=0,col=0;
38             for(int i=1;i<flag;i++){
39                 row=row*10+str[i]-'0';
40             }
41             for(int i=flag+1;i<str.length();i++){
42                 col=col*10+str[i]-'0';
43             }
44             ss(col);
45             cout<<row<<endl;
46         }
47     }    
48 } 
View Code

C

猜你喜欢

转载自www.cnblogs.com/Fighting-sh/p/10293159.html