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 12
神奇的题目,要先翻译题意,注意到出题人只会斐波那契,所以根据这个和给出的提示,
可以知道,答案是数字各个位置上的和,注意,读入的为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; }