博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #167 (Div. 2) A. Dima and Friends (模拟,简单)
阅读量:6869 次
发布时间:2019-06-26

本文共 2444 字,大约阅读时间需要 8 分钟。

A. Dima and Friends
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Dima and his friends have been playing hide and seek at Dima's place all night. As a result, Dima's place got messy. In the morning they decided that they need to clean the place.

To decide who exactly would clean the apartment, the friends want to play a counting-out game. First, all the guys stand in a circle, and then each of them shows some number of fingers on one hand (one to five), and then the boys count in a circle, starting from Dima, the number of people, respective to the total number of fingers shown. The person on who the countdown stops will clean the apartment.

For example, if Dima and one of his friends played hide and seek, and 7 fingers were shown during the counting-out, then Dima would clean the place. If there were 2 or say, 8 fingers shown, then his friend would clean the place.

Dima knows how many fingers each of his friends will show during the counting-out. Now he is interested in the number of ways to show some number of fingers on one hand (one to five), so that he did not have to clean the place. Help Dima.

Input

The first line contains integer n (1 ≤ n ≤ 100) — the number of Dima's friends. Dima himself isn't considered to be his own friend. The second line contains n positive integers, not exceeding 5, representing, how many fingers the Dima's friends will show.

The numbers in the lines are separated by a single space.

Output

In a single line print the answer to the problem.

Sample test(s)
Input
1 1
Output
3
Input
1 2
Output
2
Input
2 3 5
Output
3
Note

In the first sample Dima can show 1, 3 or 5 fingers. If Dima shows 3 fingers, then the counting-out will go like that: Dima, his friend, Dima, his friend.

In the second sample Dima can show 2 or 4 fingers.

 

1 #include 
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 using namespace std;13 #define LL long long14 #define cti const int15 #define dg(i) cout << "*" << i << endl;16 17 int main()18 {19 int n, sum, ans;20 while(cin >> n)21 {22 sum = ans = 0;23 for(int i = 0, c; i < n; i++)24 {25 cin >> c;26 sum += c;27 }28 for(int i = 1; i < 6; i++)29 if((sum + i) % (n + 1) != 1)30 ans++;31 cout << ans << endl;32 }33 return 0;34 }

 

转载地址:http://jlbfl.baihongyu.com/

你可能感兴趣的文章
如何将MathType嵌入Word 2016
查看>>
JAVA8 ARRAY、LIST操作 汇【5】)- JAVA8 LAMBDA LIST统计(求和、最大、最小、平均)...
查看>>
通过Nginx反向代理之后客户端验证码session不一致造成无法验证通过的问题解决...
查看>>
[python] PyMouse、PyKeyboard用python操作鼠标和键盘
查看>>
待整理
查看>>
(筆記) DE2與SDRAM相關資料總整理 (SOC) (DE2)
查看>>
(原創) 如何以10進位顯示8位數的七段顯示器? (SOC) (Verilog) (DE2)
查看>>
MetaModelEngine:元模型引擎开发思路
查看>>
STM32对内部Flash的保护措施
查看>>
QT练习4:编写一个查找对话框
查看>>
三道笔试题
查看>>
提升软件开发者生产力的 10 个提示
查看>>
利用Ffmpeg获得flv视频缩略图和视频时间的代码
查看>>
Markdown 11种基本语法
查看>>
LINQ 简单用法【1】
查看>>
【JavaScript学习笔记】hello world
查看>>
SharePoint 2007 采用表单验证 一段源码
查看>>
如何检查DirectX的版本(用于Windows Phone Developer Tools的安装检查)
查看>>
Convert Object to XML using LINQ
查看>>
2岁半的儿子
查看>>