codeforces 167 Div2 A
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.
처음에 제목이 잘 안 보여서 WA QAQ를 계속하고 프렌즈의 손 지수를 합쳐서 총 인원수를 본떠서 판단하면 됩니다.
코드:
1 #include
2 using namespace std;
3
4 int main( void)
5 {
6 int number, fin, sum=0;
7 int i;
8 cin>>number;
9 for( i=0; i)
10 {
11 cin>>fin;
12 sum+=fin;
13 }
14 int ans=0;
15 for( i=1; i<=5; i++)
16 {
17 if((sum+i)%(number+1)!=1)
18 ans++;
19 }
20 cout<endl;
21 return 0;
22 }
전재 대상:https://www.cnblogs.com/shadow-justice/archive/2013/02/16/2913827.html
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.