Guest User

Untitled

a guest
Jan 14th, 2016
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. string s[100005];
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(false);
  8. int n;
  9. string ans;
  10. int id;
  11. int flag1 = 0;
  12. int i;
  13. int m;
  14. int flag = 0;
  15. int cnt = 0;
  16. int j;
  17.  
  18. cin>>n;
  19. for(j = 0; j < n; j++) {
  20. cin>>s[j];
  21. m = s[j].size();
  22. if(m == 1 && s[j][0] == '0') {
  23. cout << "0";
  24. return 0;
  25. }
  26. cnt = 0;
  27. if(flag1 == 0) {
  28. for(i = 0; i < m; i++) {
  29. if(s[j][i] == '1') {
  30. cnt++;
  31. if(cnt >= 2) {
  32. id = j;
  33. ans = s[j];
  34. flag1 = 1;
  35. break;
  36. }
  37. }
  38. else if(s[j][i] != '0' && s[j][i] != '1') {
  39. id = j;
  40. ans = s[j];
  41. flag1 = 1;
  42. break;
  43. }
  44. }
  45. }
  46. }
  47. cnt = 0;
  48. if(flag1 == 0) {
  49. ans = s[0];
  50. id = 0;
  51. }
  52. for(i = 0; i < n; i++) {
  53. m = s[i].size();
  54. if(id != i) {
  55. for(j = 0; j < m; j++) {
  56. if(s[i][j] == '0') {
  57. cnt++;
  58. }
  59. }
  60. }
  61. }
  62. if(flag == 1) {
  63. cout<<0;
  64. }
  65. else {
  66. cout<<ans;
  67. for(i = 0; i < cnt; i++) {
  68. printf("%d",0);
  69. }
  70. }
  71. }
Add Comment
Please, Sign In to add comment