Cod sursa(job #2305376)
Utilizator | Data | 20 decembrie 2018 00:30:24 | |
---|---|---|---|
Problema | Deque | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.69 kb |
#include<fstream>
using namespace std;
ifstream fin("secvrest.in");
ofstream fout("secvrest.out");
long long i,x,n,dr,st,ok,v[100001];
long long rest[100001],frecv[100001];
int main()
{
fin>>n;
ok=1;
for(i=1;i<=n;++i)
fin>>v[i];
for(i=1;i<=n;++i)
{
x=v[i];
rest[i]=rest[i-1]+x%n;
rest[i]%=n;
if(frecv[rest[i]]>0)
{
dr=i;
break;
}
else if(rest[i]==0)
{fout<<"1 "<<i;
ok=0;
break;}
frecv[rest[i]]++;
}
if(ok==1)
{
st=1;
while(rest[st]!=rest[dr])
st++;
fout<<st+1<<" "<<dr;
}
}