272A - Dima and Friends - CodeForces Solution


implementation math *1000

Please click on ads to support us..

Python Code:

n=int(input())
a=sum(map(int,input().split()))
print(sum((a+i)%(n+1)!=1 for i in range(1,6)))

C++ Code:

#include<bits/stdc++.h>

#define ll long long
#define debug(x) cout<<#x<<" : "<<x<<'\n';
#define debugarr(x) for(auto i:x)cout<<i<<endl;
using namespace std;
const int MOD = 1e9+7;


int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n, temp, x = 0, ans = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> temp;
        x += temp;
    }
    
    for (int i = 1; i < 6; i++) {
        if ( (x + i) % (n + 1) == 1) ans++;
    }
    cout << 5 - ans << '\n';


    return 0;
}


Comments

Submit
0 Comments
More Questions

1485A - Add and Divide
337B - Routine Problem
1392D - Omkar and Bed Wars
76E - Points
762C - Two strings
802M - April Fools' Problem (easy)
577B - Modulo Sum
1555B - Two Tables
1686A - Everything Everywhere All But One
1469B - Red and Blue
1257B - Magic Stick
18C - Stripe
1203B - Equal Rectangles
1536A - Omkar and Bad Story
1509A - Average Height
1506C - Double-ended Strings
340A - The Wall
377A - Maze
500A - New Year Transportation
908D - New Year and Arbitrary Arrangement
199A - Hexadecimal's theorem
519C - A and B and Team Training
631A - Interview
961B - Lecture Sleep
522A - Reposts
1166D - Cute Sequences
1176A - Divide it
1527A - And Then There Were K
1618E - Singers' Tour
1560B - Who's Opposite