CF 1A1B 两个水题(简单思维+细心)

来源:互联网 发布:cax线切割编程视频教程 编辑:程序博客网 时间:2024/05/21 18:43
A. Theatre Square
time limit per test
2 seconds
memory limit per test
64 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.

Sample test(s)
input
6 6 4
output
4

       题目大意:

                   简单思维题目,如例子长为6,宽为6的卡片,用4*4的卡片覆盖,最少用几张卡片可以覆盖完。

    题目地址:Codeforces 1A

   

AC代码:

#include<cstdio>#include<iostream>using namespace std;int main(){    __int64 m,n,t,res,len1,len2;    while(~scanf("%I64d%I64d%I64d",&m,&n,&t))    {       len1=m/t;       if(m%t) len1++;       len2=n/t;       if(n%t) len2++;       res=len1*len2;       printf("%I64d\n",res);    }    return 0;}

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.

Sample test(s)
input
2R23C55BC23
output
BC23R23C55

    题目大意:

                  题意很简单R23C55是第23行第55列,BC就是55的意思。从A~Z,AA~ZZ,AAA~ZZZ。

                  主要就是数字转换成字母的时候需要考虑Z,Z比较特殊。

    题目地址:Codeforces 1B


AC代码:

#include<cstdio>#include<iostream>#include<cstring>#include<string>using namespace std;char a[18];int main(){    int n,i;    cin>>n;    while(n--)    {         cin>>a;         int len=strlen(a);         int flag=0;         int cnt=0;         for(i=1;i<len;i++)         {             if((a[i]>='0'&&a[i]<='9')&&(a[i-1]>='A'&&a[i-1]<='Z'))                cnt++;         }         if(cnt==1)     //判断是哪种情况           flag=1;         if(flag)     //输入BC23类似的          {                int t1=0,t2=0;               for(i=0;i<len;i++)               {                    if(a[i]>='A'&&a[i]<='Z')                         t1=t1*26+(a[i]-'A'+1);                      else                         t2=t2*10+(a[i]-'0');               }               cout<<"R"<<t2<<"C"<<t1<<endl;          }            else            {          //输入R23C55类似的                 int t1=0,t2=0;                 for(i=1;i<len;i++)                 {                      if(a[i]>='0'&&a[i]<='9')                         t1=t1*10+(a[i]-'0');                        else                          break;                 }                 for(int j=i+1;j<len;j++)                 {                      if(a[j]>='0'&&a[j]<='9')                         t2=t2*10+(a[j]-'0');                 }                 char rs[12],res[12];                 int xx=-1;                 while(t2)                 {                    int num=t2%26;                    if(num==0)                    {                       rs[++xx]='Z';   //这里需要分类,为Z的时候特殊                       t2--;                    }                    else                      rs[++xx]=num-1+'A';                    t2/=26;                 }                 for(i=0;i<=xx;i++)                    res[i]=rs[xx-i];                 res[++xx]='\0';                 cout<<res<<t1<<endl;            }    }    return 0;}


原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 美团极速退款后商家仍然送餐怎么办 我的拼多多商家密码忘了怎么办 特约金服扣款连续扣了两次怎么办? 拼多多拒绝退款联系客服退款怎么办 镇江新设名称申报中字号怎么办 创维电视只有声音没有图像怎么办 京东E卡有密码忘记卡号怎么办? 香香鞋上的饰品老掉怎么办 联壁金融资金冻结提现不出来怎么办 联壁金融提现不到帐怎么办 联壁金融提现迟迟不到帐怎么办 客户说平安福现金价值低怎么办 2个月宝宝肚脐凸出来怎么办 西安华润万家预付卡丢了怎么办 租房签了一年合同想走怎么办 京东寄包裹在速递易里面该怎么办 翼码科技辅助码被删掉了怎么办 用别人的身份证注册的手机号怎么办 大v线做到假线了怎么办 有个摄像头网段不同搜不到怎么办 百度网盘离线下载有违规内容怎么办 抖音上传的照片与音乐不同步怎么办 社保卡里面的钱用完了怎么办 医保卡里面的钱用完了怎么办 手机通知栏变成了搜索栏怎么办 小米手机账号密码忘了手机号怎么办 暑假工没签合同押工资了的怎么办 在日本雅虎拍卖网站买到假货怎么办 没有百度糯米账号但是买票了怎么办 拼多多商家版登陆密码忘记了怎么办 安卓下载的软件闪退怎么办 老司机影视院开通会员看不了怎么办 梦幻西游手游苹果手机打不开怎么办 拼多多笔订单被判定虚假发货怎么办 苹果手机微信接收不到信息怎么办 内衣穿32太小穿34空杯怎么办 楼下的把下水管道堵死了怎么办?? 微信绑定的手机号码已停机怎么办 绑定微信的手机号停机了怎么办验证 绑定手机停机微信怎么验证码怎么办 五菱之光雨刷开关手柄断了怎么办