ACdreamer 1069 无耻的出题人

F - 无耻的出题人
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

输入包含多组数据。

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

Output

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

Sample Input

1
2
3
4
5
-1
-2

Sample Output

1
2
3
4
5
1
2


本题题目很简单,关键在于对密码的破译。发现密码跟原码的差正好组成斐波那契数列。

最后密码的意思就是求每个位上的数字之和。是不是水题啊?
AC代码:
#include<iostream>
#include<cstdio>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<map>
#include<set>

using namespace std;

const int inf=0x7FFFFFFF;
const int MAX=1001;

#define pi acos(-1.0);
typedef long long ll;

int n,m,t;
int dp[MAX];
int a[MAX];

int main()
{
    ll a;
    while(cin>>a)
    {
        ll sum=0;
        while(a!=0)
        {
            sum+=a%10;
            a/=10;
        }
        sum=sum>0?sum:-sum;
        cout<<sum<<endl;
    }
    return 0;
}


 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值