Skip to content

Instantly share code, notes, and snippets.

@calindotgabriel
Created June 21, 2014 17:01
Show Gist options
  • Save calindotgabriel/056c85a6878c88ccc4ed to your computer and use it in GitHub Desktop.
Save calindotgabriel/056c85a6878c88ccc4ed to your computer and use it in GitHub Desktop.
#include <iostream>
#include <fstream>
#include <limits.h>
using namespace std;
ifstream f("date.in");
int n;
int m[10];
void punctulA() {
int k = 0;
for (int i = 1 ; k!=n ; i++) {
for (int j = 1 ; j <= i && k!=n; j++)
{
cout << i << " ";
k++;
}
}
}
void punctulB(int n, int &nMax, int &sMin) {
int s[200];
s[1] = 1;
for (int i = 2; ;i++) {
s[i] = s[i-1] + i;
if (n > s[i-1] && n <= s[i]) {
nMax = i;
sMin = s[i-1];
break;
}
}
}
void boboPunctC() {
int t =1;
for(int i=1;i<=9;i++)
if(m[i]!=i)
{
if(m[i+1]!=0)
{
t=0;
i=10;
}
}
else
if(m[i]==0)
for(int j=i+1;j<=9;j++)
if(m[j]!=0)
{
t=0;
i=10;
j=10;
}
if(t==1) cout<<"DA";
else cout<<"NU";
}
int main()
{
f >> n;
int y[n+1];
for(int i = 1 ; i <= n ; i ++){
f>>y[i];
m[y[i]]++;
}
int nMax , sMin;
punctulB(n, nMax, sMin);
int dif = n - sMin;
int t = 1;
for (int i = 1 ; i <= nMax ; i ++)
if (m[i] != i) {
t = 0;
}
if (m[nMax] == dif)
t = 1;
cout << t;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment