洛谷 [P4325]Modulo

题目传送门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
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值