Advertisement
Guest User

Untitled

a guest
Jul 13th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include<fstream>
  2. using namespace std;
  3. int const MAXN=1000000;
  4. int main()
  5. {
  6. ifstream in("input.txt");
  7. ofstream out("output.txt");
  8. int n, a, b, sommaA=0, prodottoA=1, sommaB=0, prodottoB=1;
  9. in>>n;
  10. char reset='a';
  11. for(int i=0;i<n;i++)
  12. {
  13. char app;
  14. in>>app;
  15. int a=app-96; //a=1, b=2.....
  16. sommaA+=a;
  17. sommaA=sommaA%1000000007;
  18. prodottoA*=a;
  19. prodottoA=prodottoA%1000000007;
  20. }
  21. for(int i=0;i<n;i++)
  22. {
  23. char app;
  24. in>>app;
  25. int b=app-96;
  26. sommaB+=b;
  27. sommaB=sommaB%1000000007;
  28. prodottoB*=b;
  29. prodottoB=prodottoB%1000000007;
  30. }
  31. if(sommaA==sommaB && prodottoA==prodottoB)
  32. out<<1;
  33. else out<<0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement