题目传送门OvO
题目描述
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.
输入输出格式
输入格式:
The input will contain 10 non-negative integers, each smaller than 1000, one per line.
输出格式:
Output the number of distinct values when considered modulo 42 on a single line.
好,还是大概的翻译一下题目(摘自luogu的翻译)
给出10个整数,问这些整数%42后有多少个不同的余数。 输入
输入包含10个小于1000的非负整数,每行一个。 输出
输出它们%42后,有多少个不同的余数。
还是很简单的
一边读入一边记录进桶(存入数组),a[x%42],把所有%42后的答案记录下来,
最后一遍循环统计:
i=0…41 a[i]==1 ans++
意思就是枚举0到41(所有数%42都只会得出0~41),如果这十个数中有一个数%42等于枚举的数(因为一开始已经记录进a数组,所以直接判断a),计数器就加1.
大概这么写:
#include<cstdio>
using namespace st