• codeforce 1B


    orz ,感觉一道很傻的模拟题,因为细节wa了好多回啊....感觉自己今天写的代码带毒...

    #include <stdio.h>
    #include <stack>
    #include <istream>
    #include <map>
    #include <math.h>
    #include <string.h>
    #include <set>
    #include <vector>
    #include <string>
    using namespace std;
    const int maxn = 1e5 + 1;

    char sum2[maxn];
    long long int solve(long long int temp)
    {
    int len = strlen(sum2);
    long long int res = 0;
    long long int fuck =1;
    for(int i = 0;i<len;i++)fuck*=10;
    for(int i = 0;i<len;i++){
    res+=fuck*(sum2[i]-'0');
    fuck/=10;
    }
    return res/10;
    }
    int main() {
    int t;
    scanf("%d", &t);
    getchar();
    for (int i = 0; i < t; i++) {
    char str[maxn];
    memset(str,'',sizeof(str));
    memset(sum2,'',sizeof(sum2));
    scanf("%s", str);
    getchar();
    int len = strlen(str);
    //printf("%s",str);
    char sum1[maxn],top1=0,top2=0;
    memset(sum1,'',sizeof(sum1));
    //long long int sum1 = 0, sum2 = 0;
    int len1 = 1, len2 = 1;
    for (int j = 0; j < len; j++) {
    if (str[j] <= '9'&&str[j] >= '0' && !top1) {
    for (int k = j; str[k] <= '9'&&str[k] >= '0'&&k < len; k++) {
    sum1[top1++]=str[k];
    j++;
    }
    j--;
    }
    else if (str[j] <= '9'&&str[j] >= '0' && top1) {
    for (int k = j; str[k] <= '9'&&str[k] >= '0'&&k < len; k++) {
    //sum2 += (str[k] - '0')*len2;
    //len2 *= 10;
    sum2[top2++]=str[k];
    j++;
    }
    j--;
    }
    }
    // puts(sum1);
    if (!top2) {
    printf("R%s",sum1);
    int l = 0;
    while (!(str[l] <= '9'&&str[l] >= '0')) {
    l++;
    if(l>=len)break;
    }
    // printf("%d** ",l);
    long long int temp = (long long int)(pow(26, l - 1) + 0.5);
    //printf("%lld** ",temp);
    int r = 0;
    long long int ans=0;
    while (r < l) {
    ans += (temp*(str[r] + 1 - 'A'));
    temp /= 26;
    r++;
    }
    printf("C%lld ", ans);
    }
    else {
    char str1[maxn];
    int top =0;
    long long int temp=solve(top2);
    // printf("%lld*** ",temp);
    bool f=1;
    while (temp) {
    // printf("%c** ",temp%26-2+'A');
    str1[top++]=((temp)%26-1+26)%26+'A';
    // printf("%d*** ",((temp)%26-1+26)%26);
    if(temp%26==0)
    {
    f=0;
    }
    temp /= 26;
    if(f==0)temp-=1;//这里wa了好多回...但其实我不知道为什么,改了之后就AC了...求大神告知orz
    f=1;
    }

    // printf("%d*** ",top);
    // if(i==55)printf("%s***** ",str);
    for(int h =top-1;h>=0;h--)printf("%c",str1[h]);
    printf("%s",sum1);
    printf(" ");
    }
    }
    return 0;
    }

    我身后空无一人,我怎敢倒下
  • 相关阅读:
    ThinkPHP模版验证要注意的地方
    js关闭子页面刷新父页面
    js替换字符指定字符方法
    Ubuntu安装后的一些配置
    Docker入门
    RabbitMQ 基本概念和使用
    JAX-WS注解
    Linux 常用命令
    ubuntu16.04 搭建 Mysql服务器
    ubuntu 安装 Tomcat
  • 原文地址:https://www.cnblogs.com/DreamKill/p/8711641.html
Copyright © 2020-2023  润新知