Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<fstream>
- using namespace std;
- int const MAXN=1000000;
- int main()
- {
- ifstream in("input.txt");
- ofstream out("output.txt");
- int n, a, b, sommaA=0, prodottoA=1, sommaB=0, prodottoB=1;
- in>>n;
- char reset='a';
- for(int i=0;i<n;i++)
- {
- char app;
- in>>app;
- int a=app-96; //a=1, b=2.....
- sommaA+=a;
- sommaA=sommaA%1000000007;
- prodottoA*=a;
- prodottoA=prodottoA%1000000007;
- }
- for(int i=0;i<n;i++)
- {
- char app;
- in>>app;
- int b=app-96;
- sommaB+=b;
- sommaB=sommaB%1000000007;
- prodottoB*=b;
- prodottoB=prodottoB%1000000007;
- }
- if(sommaA==sommaB && prodottoA==prodottoB)
- out<<1;
- else out<<0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement