o.boj 1047 MODULO
2011-12-17 10:05
274 查看
注:最近这一系列ACM的内容,都是2年多之前的代码,自己回顾一下。
MODULO
Submit: 1398 Accepted:830
Time Limit: 1000MS Memory Limit: 65556K
Description
Given two integers A and B, A modulo B is the remainder when dividing A by B. For example, the numbers 7, 14, 27 and 38 become 1, 2, 0 and 2, modulo 3. Write a program that accepts
10 numbers as input and outputs the number of distinct numbers in the input, if the numbers are considered modulo 42.
Input
The input will contain 10 non-negative integers, each smaller than 1000, one per line.
Output
Output the number of distinct values when considered modulo 42 on a single line.
Sample Input
39
40
41
42
43
44
82
83
84
85
Sample Output
6
Hint
In the example, the numbers modulo 42 are 39, 40, 41, 0, 1, 2, 40, 41, 0 and 1. There are 6 distinct numbers.
Source
Croatian Open Competition in Informatics
求一组数据模42所得的各不相等的余数的个数。水题,直接申请一个42位辅助数组记录相应余数是否出现过,没出现过的count+1即可
MODULO
Submit: 1398 Accepted:830
Time Limit: 1000MS Memory Limit: 65556K
Description
Given two integers A and B, A modulo B is the remainder when dividing A by B. For example, the numbers 7, 14, 27 and 38 become 1, 2, 0 and 2, modulo 3. Write a program that accepts
10 numbers as input and outputs the number of distinct numbers in the input, if the numbers are considered modulo 42.
Input
The input will contain 10 non-negative integers, each smaller than 1000, one per line.
Output
Output the number of distinct values when considered modulo 42 on a single line.
Sample Input
39
40
41
42
43
44
82
83
84
85
Sample Output
6
Hint
In the example, the numbers modulo 42 are 39, 40, 41, 0, 1, 2, 40, 41, 0 and 1. There are 6 distinct numbers.
Source
Croatian Open Competition in Informatics
求一组数据模42所得的各不相等的余数的个数。水题,直接申请一个42位辅助数组记录相应余数是否出现过,没出现过的count+1即可
#include <stdio.h> main() { int num[43] = {0}; int temp, i, j, count = 0; for (i = 0; i < 10; i++) { scanf("%d", &temp); temp %= 42; if (!num[temp]) { num[temp]++; count ++; } } printf("%d\n", count); // system("pause"); return 0; }
相关文章推荐
- ZOJ 1047 物体堆的边界
- boj problem 1331 思路:快排分块 按块查找 问题:全局数组时可以定义到500W的 main函数下的数组不行~ 另外c语言比c++快 TLE可以考虑C~~具体原因待解决
- boj 1347 简单数组问题 在一个二维数组中 a[i][j]=a[i][j]+a[i-1][j]+a[i][j-1]-a[i-1][j-1] 则a[i][j]为i j位置左上侧所有元素之和
- TACAS11: Canonized Rewriting and Ground AC Completion Modulo Shostak Theories
- BOJ212 树的先序遍历
- BOJ1509 海边 dijstra 最短路
- o.boj 1039 Vitamin部落II-祭祀舞蹈
- o.boj 1417 Cloudiris's Flower
- o.boj 1477 cloudiris的巧克力账本
- BOJ 292 MABODX
- n.boj 389 Shaking Your Cellphone(6th bupt acm problem D)
- poj 1047 Round and Round We Go
- HDOJ 1047 大数加法 水
- HDU 1047
- 1047. Student List for Course
- 1047 单个字母大小写互换
- BOJ 953 flower
- BOJ 1578 Maximum
- Integer Inquiry_hdu_1047(大数).java
- HDU-1047 Integer Inquiry 大数相加