Advertisement
a53

PermutarePow

a53
Sep 22nd, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. ///Indicatie
  2. ///Se consideră graful orientat corespunzător arcelor formate din pozițiile elementelor permutării și valorile acestora.
  3. #include <fstream>
  4. #include <cmath>
  5. using namespace std;
  6. ifstream f("permutarepow.in");
  7. ofstream g("permutarepow.out");
  8.  
  9. int main()
  10. {
  11. int n,x,sol=0;
  12. f>>n;
  13. for(int i=1;i<=n;++i)
  14. {
  15. f>>x;
  16. x=abs(1-x)+1;
  17. if(x>sol)
  18. sol=x;
  19. }
  20. g<<sol;
  21. return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement