ACdream 1069 无耻的出题人

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

神奇的题目,要先翻译题意,注意到出题人只会斐波那契,所以根据这个和给出的提示,

可以知道,答案是数字各个位置上的和,注意,读入的为longlong,如果是负数,不能直接取反

因为longlong的正数最大值要小于负数最大值。

#include<set>
#include<map>
#include<ctime>
#include<cmath>
#include<stack>
#include<queue>
#include<bitset>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#define rep(i,j,k) for (int i = j; i <= k; i++)
#define per(i,j,k) for (int i = j; i >= k; i--)
#define loop(i,j,k) for (int i = j;i != -1; i = k[i])
#define lson x << 1, l, mid
#define rson x << 1 | 1, mid + 1, r
#define fi first
#define se second
#define mp(i,j) make_pair(i,j)
#define pii pair<int,int>
using namespace std;
typedef long long LL;
const int low(int x) { return x&-x; }
const double eps = 1e-8;
const int INF = 0x7FFFFFFF;
const int mod = 10000;
const int N = 10000;
const int read()
{
	char ch = getchar();
	while (ch<'0' || ch>'9') ch = getchar();
	int x = ch - '0';
	while ((ch = getchar()) >= '0'&&ch <= '9') x = x * 10 + ch - '0';
	return x;
}
int T;
long long n;

int main()
{
	while (scanf("%lld", &n) != EOF)
	{
		int res = 0;
		while (n) res += n % 10, n /= 10;
		printf("%d\n", abs(res));
	}
	return 0;
}


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值