zoukankan      html  css  js  c++  java
  • Codeforces Round #167 (Div. 2) A. Dima and Friends (模拟,简单)

    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 <iostream>
     2 #include <string>
     3 #include <set>
     4 #include <map>
     5 #include <vector>
     6 #include <stack>
     7 #include <queue>
     8 #include <cmath>
     9 #include <cstdio>
    10 #include <cstring>
    11 #include <algorithm>
    12 using namespace std;
    13 #define LL long long
    14 #define cti const int
    15 #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 }
  • 相关阅读:
    windows下GitHub的SSH Key 配置
    bootdo开源项目修改代码后页面无效
    携程第二场预赛 1003:位图像素的颜色(水题,判断点是否在矩形内)
    hdu 2105:The Center of Gravity(计算几何,求三角形重心)
    《随机出题软件》&《随机分队软件》源码(Windows API)
    hdu 1426:Sudoku Killer(DFS深搜,进阶题目,求数独的解)
    fzu 1330:Center of Gravity(计算几何,求扇形重心)
    hrbustoj 1104:Leyni, LOLI and Line(解析几何,斜截式的应用)
    poj 3348:Cows(计算几何,求凸包面积)
    《linux系统及其编程》实验课记录(五)
  • 原文地址:https://www.cnblogs.com/cszlg/p/2924683.html
Copyright © 2011-2022 走看看