首页 > ACM题库 > HDU-杭电 > HDU 3953-I’ll play a trick on you-高精度-[解题报告]HOJ
2015
04-14

HDU 3953-I’ll play a trick on you-高精度-[解题报告]HOJ

I’ll play a trick on you

问题描述 :

Please look the picture carefully. Then I’ll give you two integers and your task is output the third one.
Please never doubt the picture.
Fruit Ninja

输入:

The first line is a number T(1<=T<=30), represents the number of case. The next T blocks follow each indicates a case.
Each case contains two integers A,B (1<=B<=A<=10100)

输出:

The first line is a number T(1<=T<=30), represents the number of case. The next T blocks follow each indicates a case.
Each case contains two integers A,B (1<=B<=A<=10100)

样例输入:

3
99 72
45 27
39 18

样例输出:

Case 1: 27
Case 2: 18
Case 3: 21
Hint
If you have any idea to work out the ? and explain why but couldn't get Accepted , please email me ([email protected]), the first person will get 100RMB from me.

题目有点坑,开始以为大数相减,最后发现最后一个21  13    7,这个数据不对!挺好的一道水题!!!

#include<iostream>
#include<string>
using namespace std;
char a[105], b[105];

int main()
{
	int T, t = 1;
	scanf("%d", &T);
	getchar();
	while(T--)
	{
		int sum = 0, i;
		scanf("%s %s", a, b);
		for( i=0; a[i] != '\0'; i++ )
			sum += a[i] - '0';
		for( i=0; b[i] != '\0'; i++ )
			sum += b[i] - '0';
		printf("Case %d: %d\n", t++, sum);
	}
	return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

参考:http://blog.csdn.net/asure__cpp/article/details/8752084


  1. 有一点问题。。后面动态规划的程序中
    int dp[n+1][W+1];
    会报错 提示表达式必须含有常量值。该怎么修改呢。。

  2. 我还有个问题想请教一下,就是感觉对于新手来说,递归理解起来有些困难,不知有没有什么好的方法或者什么好的建议?

  3. 第二个方法挺不错。NewHead代表新的头节点,通过递归找到最后一个节点之后,就把这个节点赋给NewHead,然后一直返回返回,中途这个值是没有变化的,一边返回一边把相应的指针方向颠倒,最后结束时返回新的头节点到主函数。