A8957 | Dima and Friends
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
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.
The numbers in the lines are separated by a single space.
输出格式
In a single line print the answer to the problem.
输入输出样例
输入 #1
1 1
输出 #1
3
输入 #2
1 2
输出 #2
2
输入 #3
2 3 5
输出 #3
3
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.
In the second sample Dima can show $2$ or $4$ fingers.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted