On the planet Mars a year lasts exactly n days (there are no leap years on Mars). But Martians have the same weeks as earthlings — 5 work days and then 2 days off. Your task is to determine the minimum possible and the maximum possible number of days off per year on Mars.
The first line of the input contains a positive integer n (1 ≤ n ≤ 1 000 000) — the number of days in a year on Mars.
Print two integers — the minimum possible and the maximum possible number of days off per year on Mars.
14
4 4
2
0 2
In the first sample there are 14 days in a year on Mars, and therefore independently of the day a year starts with there will be exactly 4days off .
In the second sample there are only 2 days in a year on Mars, and they can both be either work days or days off.
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define LL __int64
const int maxm=1e5+10;
int a[maxm];
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
int sum1=0,sum2=0;
sum1=(n/7)*2;
if(n%7>=6)
sum1++;
sum2=(n/7)*2;
if(n%7==0)
sum2==sum2;
else if(n%7==1)
sum2++;
else if(n%7>=2)
sum2+=2;
printf("%d %d\n",sum1,sum2);
}
return 0;
}
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define LL __int64
const LL maxm=1e7+10;
LL d[maxm];
LL a[maxm];
int main()
{
LL n,k;
while(scanf("%I64d%I64d",&n,&k)!=EOF)
{
for(LL i=1;i<=n;i++)
scanf("%I64d",&d[i]);
LL ans=0;
LL cnt=0;
for(LL i=1;i<=2e9+10;i+=ans)
{
a[cnt++]=i;
ans++;
}
LL x=upper_bound(a,a+cnt,k)-a;
// printf("%d\n",a[x-1]);
printf("%I64d\n",d[k-a[x-1]+1]);
}
return 0;
}
#include<stdio.h>
#include<string.h>
#include<string>
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
#define LL __int64
const LL maxm=1e6+10;
const LL inf=1e10+10;
LL b[maxm];
LL c[maxm];
map<LL,LL>q;
int main()
{
LL n;
while(scanf("%I64d",&n)!=EOF)
{
q.clear();
LL a;
for(LL i=0;i<n;i++)
{
scanf("%I64d",&a);
q[a]++;
}
LL m;
scanf("%I64d",&m);
for(LL i=0;i<m;i++)
{
scanf("%I64d",&b[i]);
}
for(LL i=0;i<m;i++)
{
scanf("%I64d",&c[i]);
}
LL M=0;
LL index=0;
for(LL i=0;i<m;i++)
{
if(M<=q[b[i]]*inf+q[c[i]])
{
M=q[b[i]]*inf+q[c[i]];
index=i+1;
}
}
printf("%I64d\n",index);
}
return 0;
}