SHARE
TWEET

Untitled

a guest Nov 6th, 2019 13 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def main():
  2.     N = int(input())
  3.     A = list(map(int, input().split()))
  4.     ans = 0
  5.     for i in range(N):
  6.         if A[A[i]-1] == i + 1:
  7.             ans += 1
  8.     print(ans//2)
  9.  
  10.  
  11. if _name_ == "_main_":
  12.     main()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top