[GDUT-ACM]

Problem B: 神奇的编码

Description

假如没有阿拉伯数字,我们要怎么表示数字呢
小明想了一个方法如下:
1 -> A
2 -> B
3 -> C
….
25 -> Y
26 -> Z
27 -> AA

28 -> AB
….

现在请你写一个程序完成这个转换

Input

输入的第一个数为一个正整数T,表明接下来有T组数据。
每组数据为一个正整数n ( n <= 1000)

Output

对于每个正整数n,输出他对应的字符串

Sample Input

3
1
10
27

Sample Output

A
J
AA

没什么神奇的,本质还是进制转换

心急如焚之时,代码风格无比混乱;那个26的倍数的特殊处理,是个大痛点,AC一次耗时25min


#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define CLEAR(a) memset((a),0,sizeof((a)))
  
using namespace std;
  
typedef long long LL;
const double pi = acos(-1.0);
const int maxn=1e4;
const int inf=99999999;
const double eps=1e-3;
  
  
int n;
  
void init();
void solve();
void outp();
  
int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
        {
            string str;
            scanf("%d",&n);
            //n+=(n-1)/26;
            //n++;
            //if (n%26==0) n--;
            while(n)
            {
                char ch=(n%26)?n%26+'A'-1:(n--,'Z');
                str=ch+str;
                n/=26;
            }
            printf("%s",str.c_str());
            puts("");
        }
    return 0;
}
  
void solve()
{
}
  
void init()
{
    for(int i=1;i<=n;i++)
    {
  
    }
}
  
void outp()
{
    printf("\n");
}
  
/**************************************************************
    Problem: 1112
    User: semprathlon
    Language: C++
    Result: Accepted
    Time:0 ms
    Memory:1484 kb
****************************************************************/

=======================分隔符==============================

题E
自我感觉正确,可是未能在结束前提交。。

int n;
 
char* solve(double v,double d);
 
int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
        {
            double v,d;
            scanf("%lf%lf",&v,&d);
            puts(solve(v,d));
        }
    return 0;
}
 
char* solve(double v,double d)
{
    return (char*)(((v*v*sqrt(2.0))/10.0-d>eps)?"Fire":"Retreat");
}



题A
耗时16min,循环队列,简直没有TLE/MLE的理由

int n;
int que[maxsize],h,r;
  
int EnQ(int id)
{
    if ((r+1)%maxsize!=h)
    {
        r=(r+1)%maxsize;
        que[r]=id;
        return 0;
    }
    else return -1;
}
  
int DeQ()
{
    if (h!=r)
    {
        int t=h;
        h=(h+1)%maxsize;
        return que[t];
    }
    else return -1;
}
  
int Query(int k)
{
    if (h==r) return -1;
    int t=(h<=r)?r-h:maxsize-r+h;
    return (t>=k)?que[(h+k)%maxsize]:-1;
}
  
int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
        {
            CLEAR(que);h=r=0;
            int cas,k;
            scanf("%d",&n);
            for(int i=0;i<n;i++)
            {
                scanf("%d",&cas);
            switch(cas)
            {
                case 1:scanf("%d",&k);EnQ(k);break;
                case 2:DeQ();break;
                case 3:scanf("%d",&k);
                if (Query(k)>=0) printf("%d\n",Query(k));
                else puts("na li you zhe me duo ren");
                break;
            }
            }
        }
    return 0;
}




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值