EOJ1004-1010

1004. 值班

单点时限: 2.0 sec

内存限制: 256 MB

马上就到 6 月份了,又要安排实验室值班人员了。Robin 现在只有一份表格,上面记录着每个人每天是否可以值班。

输入格式

第一行为一个整数 N,表示有 N​ 个人愿意参加值班。

接下来 N 行:

 表示第 i个人在 6 月份的第j 个可以值班的时间, 每行均以 -1 结束

输出格式

输出 yes 如果 6 月份每天都有人值班, 否则输出 no

样例

input

2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 -1
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 -1

output

yes
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
    int june[31] = { 0 };
    int n = 0, day = 0, totalDay = 0;
    scanf("%d", &n);
    while (n--) {
        while (scanf("%d", &day) && day != -1)
            if (june[day] == 0) 
            {
                june[day] = 1;
                totalDay++;
            }
    }

    if (totalDay == 30)
        printf("yes\n");
    else
        printf("no\n");

    return 0;
}

1005. SQUINT

单点时限: 2.0 sec

内存限制: 256 MB

Write a program to calculate integer square roots.

输入格式

Its only line consists of an integer 0⩽n≤263 .

输出格式

Its only line consists of the smallest nonnegative integer q such that q2⩾n .

样例

input

122333444455555

output

11060446
#include <stdio.h>
int main() {
    long long int num = 0;
    scanf("%lld", &num);
    unsigned long long sqrt = 0, weight = 1000000000;

    for (; weight > 0; weight /= 10) 
    {
        while (sqrt * sqrt < num)
            sqrt += weight;
        if (sqrt * sqrt == num) 
        {
            sqrt--;
            break;
        }
        sqrt -= weight;
    }

    printf("%llu\n", sqrt + 1);

    return 0;
}

 

1006. 求斜边

单点时限: 2.0 sec

内存限制: 256 MB

有一个直角三角形,已知两直角边长度,求斜边长度。

输入格式

多组测试数据,每行两个整数,代表两个直角边的长度。

输出格式

对于每组测试数据输出你求得的结果,每组输出占一行。保留 3 位小数。

样例

input

3 4
5 12
1 1

output

5.000
13.000
1.414
#include <stdio.h>
#include<math.h>
int main()
{
	int a, b, c2;
	double c;
	while (scanf("%d %d", &a, &b) != EOF)
	{
		 c2=a * a+ b* b;
		c = pow(c2,0.5);
		printf("%.3lf\n", c);
	}
	return 0;
}

 

1007. 求 x 的 y 次方

单点时限: 2.0 sec

内存限制: 256 MB

可以用 pow 函数来完成。

如要求 2.3 的 3.7 次方,则调用函数 pow(2.3,3.7);

输入格式

多组测试数据,每行两个小数 x,y。

输出格式

对于每组测试数据输出 x 的 y 次方,每组输出占一行。保留 3 位小数。

样例

input

2.0 4.0
1.0 100.0
1.414 2

output

16.000
1.000
1.999
#include<stdio.h>
#include<math.h>
int main()
{
	double x,y;
	double num;
	while (scanf("%lf %lf", &x, &y) != EOF)
	{
		num = pow(x,y);
		printf("%.3lf\n", num);
	}
	return 0;
}

1008. sum of digit
单点时限: 2.0 sec
内存限制: 256 MB
Write a program which computes the digit number of sum of two integers a and b.
输入格式
The first line of input gives the number ofcases, N(1 ≤N≤ 100). Ntest cases follow.Each test case consists of two integers a and b which are separeted by a space in a line, (0 < a,b< 100000000)
输出格式
For each test case, print the number of digits of a+b 

样例

input

3
5 7
1 99
1000 999

output

2
3
4
#include<stdio.h>
int main()
{
	int n;
	int a, b,c;
	int count = 0;
	scanf("%d", &n);
	for (n; n > 0; n--)
	{
		scanf("%d %d", &a, &b);
		c = a + b;
		do
		{
			c = c / 10;
			count++;
		} while (c > 0);
		printf("%d\n", count);
		count = 0;
	}
}

1009.工程
单点时限: 2.0 sec
内存限制: 256 MB
Castor 在 ECNU 工厂工作。总厂有一条生产线,现在生产流水线上排队的零件总数为 M。当前 Castor 开始加工第一个零件。流水线上的零件总是按顺序加工的。例如零件 i 必须是在零件 i+1 之前加工
现在 Castor 只需要再加工 K(K≤ M)个零件就能休息了,Castor 想知道他还要工作多长时间才能休息
输入格式
第一行为一个整数 T,表示测数数据的组数
对每组测试数据
第一行有两个整数M,K(1≤K≤M≤1000)
然后一行有 M 个数字 第之个数字表示零件队列的第之个零件需要加工的时间为 t;(1 ≤t;≤ 10000)
输出格式
每组数据输出一行,每行只有一个整数表示 Castor 还需要工作多长时间 

样例

input

2
3 2
5 2 3
3 1
1 2 3

output

7
1
#include <stdio.h>
int main()
{
	int T,M,K;
	int time=0;//总加工时长
	scanf("%d", &T);
	int a[1000];//存放加工零件的时间
	for (T; T > 0; T--)
	{
		scanf("%d %d", &M, &K);
		for (int i = 0; i < M; i++)
		{
			scanf("%d", &a[i]);
		}
		for (int j = 0; j < K; j++)
		{
			time += a[j];
		}
		printf("%d\n", time);
		time = 0;
	}
	return 0;
}

 1010.计算2的N次方
单点时限: 2.0 sec
内存限制: 256 MB
给定一个整数 N(0 ≤ N≤ 30),输出 2N
输入格式
第1 行:一个整数 T'(1 < T < 10) 为问题数。接下来共 T 行整数,对应每个问题有1 行,表示N,
输出格式
对于每个问题,输出一行问题的编号(0 开始编号,格式:等)case #0:然后对应每个问题在一行中输出 $2^N。

样例

input

3
0
30
4

output

case #0:
1
case #1:
1073741824
case #2:
16
#include <stdio.h>
#include<math.h>
int main()
{
	int T, N;
	long long int c;
	scanf("%d", &T);
	for (int i = 0; i < T; i++)
	{
		scanf("%d", &N);
		printf("case #%d:\n",i);
		c = pow(2, N);
		printf("%lld\n", c);
	}
	return 0;
}

  • 30
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值