EOJ 1001-1003

1001. A + B Problem

单点时限: 1.0 sec

内存限制: 256 MB

输入格式

Two integer a,b (0≤a,b≤10). Process to end of file.

输出格式

For each case, output a+b in one line.

样例

input

1 1
2 3

output

2
5
#include <stdio.h>
int main()
{
	int a, b;
	while (scanf("%d %d", &a, &b) != EOF)
	{
		printf("%d\n", a + b);
	}
	return 0;
}

 1002. 几位数?

单点时限: 2.0 sec

内存限制: 256 MB

旺财视力越来越差了,刚好这几天数学作业总是要对很长很长的数字进行加减,每次旺财看到这么长的数字总想先数数它是几位数。

可他数着数着眼就花了,不得不重新从个位数起,现在想请你写程序帮他解决这个问题。

输入格式

每行输入一个非负整数,这个非负整数不会超过 1024 位。

行数不会超过 100 行。

输出格式

每行只输出一个正整数,为对应的非负整数的位数。

样例

input

1
100123
12345678901234567890

output

1
6
20
#include <stdio.h>
#include <string.h>
 
int main()
{
	char a[1025] = {0};
	while(scanf("%s", a) != EOF)
            printf("%d\n", strlen(a));
	return 0;
}

1003. 计算 a 的 n 次方

单点时限: 2.0 sec

内存限制: 256 MB

给定两个整数 a (0<a<10) 和 n (0≤n<20),输出 a 的 n 次方。

输入格式

第 1 行:一个整数 T (1≤T≤10) 为问题数。

接下来共 T 行。每行是由一个空格分隔的两个整数,表示 a 和 n。

输出格式

对于每个问题,输出一行问题的编号(0 开始编号,格式:case #0: 等)。

然后对应每个问题在一行中输出 a 的 n 次方。

样例

input

3
2 0
9 19
3 10

output

case #0:
1
case #1:
1350851717672992089
case #2:
59049
#include <stdio.h>
int fun( int m,int n)
{
	if (n == 0)
	{
		printf("1\n");
	}
	else
	{
		long long int tmp = 1;
		for (int a = 1; a <= n; a++)
		{
			tmp = tmp * m;
		}
		printf("%lld\n", tmp);
	}
	return 0;
}
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num; i++)
	{
		 int x, y;
		scanf("%d %d", &x, &y);
		printf("case #%d:\n", i);
		fun(x, y);
	}
	return 0;
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值