无耻的出题人
Time Limit: 2000/1000MS (Java/Others)
Memory Limit: 65536/32768KB (Java/Others)
Problem 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
Source
zju_xxx
Manager
神奇的题目,要先翻译题意,注意到出题人只会斐波那契,所以根据这个和给出的提示,可以知道,答案是数字各个位置上的和,注意,读入的为longlong,如果是负数,不能直接取反因为longlong的正数最大值要小于负数最大值。#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
int main()
{
char ch[50];
while(~scanf("%s",ch))
{
int sum=0;
int len=strlen(ch);
for(int i=0;i<len;i++)
if(ch[i]>='0'&&ch[i]<='9')
sum+=ch[i]-'0';
printf("%d\n",sum);
}
return 0;
}