ACdream 1069 无耻的出题人【Fibnacci】

32 篇文章 0 订阅
无耻的出题人
Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu

Description

听到X神要参加比赛,只会Fibnacci数的出题人被吓得哭晕在厕所。为了防止X神AK(ALL KILL)比赛题目,无耻的出题人只好在题面上做些手脚(加密)。其中一道题的题目描述如下:

hjxh dwh v vxxpde,mmo ijzr yfcz hg pbzrxdvgqij rid stl mc zspm vfvuu vb uwu spmwzh.

比赛的时候X神对题面研究了四个多小时,终于发现了一丝规律,并且破解出了前四个单词hjxh dwh v vxxpde对应是:give you a number。

但是比赛时间所剩不多,X神需要你的帮助(在解密题面之后帮他写一个可以ac的代码o(╯□╰)o)。

Input

输入包含多组数据。

每组数据一个数字 n, n在long long范围内。

Output

对于每组测试数据,输出答案。

Sample Input

1
2
3
4
5
-1
-2

Sample Output

1
2
3
4
5
1
2

根据Fibnacci数翻译给的那段英文(题目),原文和密文之间相差一个Fibnacci数。

即:原文字母序号-密文字母序号=Fibnacci(注意26为一个循环节)

题目:要我们求所给数字的各位数字的和。

AC:

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<climits>
#include<string>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
#define rep(i,j,k)for(i=j;i<k;i++)
#define per(i,j,k)for(i=j;i>k;i--)
#define MS(x,y)memset(x,y,sizeof(x))
typedef long long LL;
const int INF =0x7FFFFFFF;

int main()
{
    char str[100];
    int i,j,k;
    while(~scanf("%s",str))
    {
        int len=strlen(str);
        int sum=0;
        rep(i,0,len)
        {
           if(str[i]=='-')continue;
           else sum+=str[i]-'0';
        }
        printf("%d\n",sum);
    }
    return 0;
}

题目:

#include<stdio.h>
#include<cstring>
#include<cmath>
#include<algorithm>
char s[28]={'0','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
int main()
{
    long long a[100];
    a[0]=1;a[1]=1;
    for(int i=2;i<100;i++)
        a[i]=a[i-1]+a[i-2];
    char c[100];
    gets(c);
    for(int i=0,x=0;i<strlen(c);)
      {
         for(int j=1;j<=26;j++)
         {
             if(c[i]==s[j])
             {
                 c[i]=s[(j-a[x]%26+26)%26];
                 i++;x++;
                 break;
             }
             else if(c[i]==' '||c[i]==',')
             {
             	  i++;
             }
         }
      }
    printf("%s",c);
}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值