ENG
RUS
Timus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board
Discussion of Problem
1024
. Permutations
Where is Wrong answer #3
Posted by
Akbar Ali
16 Nov 2006 06:52
#include<iostream.h>
int main()
{
long int s=0,i,n,a[1000];
cin>>n;
for(i=1;i<=n;i++)
cin>>a[i];
i=1;
do
{
s=s+a[i];
if(a[i]<=i)break;
i=a[i];
} while(i<=n);
cout<<s<<endl;
return 0;
}
© 2000–2024
Timus Online Judge Team
. All rights reserved.