fork download
  1. #include<stdio.h>
  2. #include<iostream>
  3. #include<map>
  4. #include<algorithm>
  5. using namespace std;
  6. #define maxn 222222
  7. char si[maxn],s2[maxn];
  8. int sl1,sl2,i,j;
  9. unsigned int ha,hh[maxn],n;
  10. map<unsigned int,int>was;
  11. int main(){
  12. freopen("bad-hashing.in","r",stdin);
  13. freopen("bad-hashing.out","w",stdout);
  14. srand(time(NULL));
  15. cin>>n;
  16. ha=0;
  17. for(i=1;i<=100000;i++){
  18. si[i]=97;sl1=i;
  19. ha=ha*n+si[i];
  20. hh[i]=ha;
  21. if(was[ha]){
  22. for(j=1;j<=i;j++)putchar(97);puts("");
  23. for(j=1;j<=was[ha];j++)putchar(97);puts("");
  24. return 0;
  25. }
  26. was[ha]=i;
  27. }
  28. while(1);
  29. return 0;
  30. }
Success #stdin #stdout 0.02s 4156KB
stdin
Standard input is empty
stdout
Standard output is empty