fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <ctype.h>
  4. #include <string.h>
  5. #include <stdlib.h>
  6.  
  7.  
  8.  
  9. int main(){
  10. int t; scanf("%d", &t);
  11. getchar() ;
  12.  
  13. while(t--){
  14. scanf("\n") ;
  15. // nhap
  16. char s[1100];
  17. fgets(s,1100,stdin);
  18.  
  19. int sum = 0;
  20. int dem = 0;
  21.  
  22. if (s[strlen(s)-1] == '\n') s[strlen(s)-1] = '\0';
  23.  
  24. int luu = 0, luu2 = 0;
  25. int luu1 = 0;
  26. int max = 0;
  27. int luu3 = 0;
  28.  
  29.  
  30. for (int i = 0; i< strlen(s); i++){
  31. // khoi tao lai tong sau moi vong
  32. sum = 0;
  33.  
  34. //ktr 3 ki tu lien nhau
  35. for(int j = 0; j<3 ; j++){
  36. sum = sum * 10 + (s[i + j] - '0');
  37. }
  38.  
  39. // luu bien i de su dung
  40. luu1 = i;
  41.  
  42.  
  43.  
  44. //so sanh sum voi 100 neu i # 0
  45. if (sum == 100 && i>0) {
  46.  
  47.  
  48. // xep lai mang
  49. for (int k = luu1; k < strlen(s)-3; k++){
  50. s[k] = s[luu1+3];
  51. luu1++;
  52. }
  53. s[strlen(s) - 3] = '\0';
  54. dem+=3;
  55. // xet lai i tu i-2 de xem co bien lai thanh 100 ko
  56. i = -1;
  57. }
  58.  
  59. // so sanh i voi 100 neu i = 0
  60. else if (sum == 100 && i==0){
  61.  
  62.  
  63. //xep lai mang
  64. for (int k = luu1; k<strlen(s)-3; k++){
  65. s[k] = s[luu1+3];
  66. luu1++;
  67. }
  68. s[strlen(s) - 3] = '\0';
  69. i = -1;
  70. }
  71. }
  72.  
  73. printf("%d\n", strlen(s));
  74.  
  75. }
  76. return 0;
  77. }
Success #stdin #stdout 0.02s 5276KB
stdin
1
10100011010100010100011010110010001110010100001010111101000100100001110110111110110100010101011000101011001111010011010101110110101010001101001010101110000001100000011101001010111100001011111000101111010000001000100100100011101101011111000110100011111101001011010001010111111011110111001001001010110010110100001100011000011110000010111111011101010101101000010101111110000101010010000110001100110010110110001000110110100010111001010100001010000100100110111110011101100000100110111100001100110101101000000110001101100100111011000011010101110001111100010010111000101011101110000101111000011000111101101001111110011001011010101010111110101011010101001011110011110011010101011010011000000000011100010010001000100110110110011010101110010111011001100101101011010101101101000111010011000010011011100100110111011101101010111000111110010011011010101001100111001110000111001100100001111100011101011011111001110100000111011110101111010111101110001011000100100100010010011101100010001010100110111001110110111110100110100001101010100000101111111010111101100010010101111001011100011010100110000110010111111011101100110001100100010101110011001100110111101101010011010101000011011101000010101010000100100010101100111111110011101100110100101101101000101011111110011100010101111010101010111100101110011010011010111011011011011101101000001111001010100001010100101110001111010010101010001001110010001101111110010001011101110001011101101101101001010110001010111001010011111110111000010010000100100000100111010100111111100010001100000100000011010110100101110100001010010101000100010110100110110001110101001011111010011011001100011001011110111001100100011111000111011011101010101001100100111100101100100100001110101101001001011101001010001011011111100101110011001011100100000101001001111001001010011111111110110111111110001110011101111100100101001000100011001011001011000111110011001110010000111001011110010000011000001001101001101100111110001101011100101111100001111111110100110001100001100000011000101011000110010110010100100000011111110010110001110101000110101000100001110000110001111111011000001000011101001001010110111011100110000000101011010111010010111110101000101111111001011110011110000011011111010011000101001101000110101101101001001011110010011010011001110011100011010000111000100111100111001010011001000000101111101110100000001000000001101000001000001111000000110101000101000111100011100110001111001110101000000001010100000001010011000000001000000110101011000100010011110110011100000000000001110001111111010100100000000011101011000000001000000001110101010101100001100001101010001101110011000000010011011000111010000010011000010111101011001111010011011100110001010010010011101001001010011110101110011101000110000101100110111101010111011011010111011010110011000000100101101110101110100000001010010101000100010011000000100010100000101001101001110000110001110000111111111100111000100101110110001101100110001000000110001000001111110111010000111110000101010000100011010011001001101110001100001111000110010001110111100011101001111010001010111011001010110111010010010011101011001001010001000000100010101110111000000101101000001011001101010101111001110111110101000100011000000110010101101010111111101001000100110001010110001100001001011111010101010000010101110111110000000011010101000000101000110001001100001001101101101110001101000011000101011000000101100110110111001010011101100110010110101011111101010101010010001110111001111010010110011010011101011110100011100110010010000110001100111010000011001011010111011000101100001001100011010110110011001001000101111110111001110000110110000110111000101101010101001000111001101001010110001000011011011110101011100000000111101100001100011101100100001110110010111011011100011100100110011010001100101111000001000000100011111001001010101000111011111110110101100000010110100010111000110101001001001010110100101111100011011101000101010111111011000101010100110000101010010100001010100111101001010010100001000010011001010011010001001101111101000101011000010011010000001011001111011000110001010111001111111110110000101100100101011011000101100001110111000010101110000110110111010011000001010010111111101111110000011100011001010010011000100100011100011101000001111001001101001000001001111011001100101001100100000010111101100000000101110110001111001011001110001010101000010011100010000110000000011110011101001010111100100101111000111111110000100011010110000110101100111101111111000101011100001000001001011000000011010011111010000011101110010110000010001111101111010001100110011001100000001111001001100010101110101001000100010000100001011111110011010111010011000111010101001100111111000101011111101011111111010111001101101100010110101000110001100110001010000000100011101101010110010100100000010100000010011000110100011001010100000000001110010010111010000101101100110111010111000010010011100000100111111000100011010001000100110111010011101010110100000000100101010111010010101011100010110101111010110111011001111111011000010011100110100000100100101011100111011000001111010100111101110111011011101101111000110101010111010111111100101101111101100001101111000001111011110110111111001000001101001011001011111001100001000000110100100101111100011100010111001000101110010111001101000001000100110001011111001011100111110110111111111100000001111100010011100000100000001011111110010111100011000011001110101000001000000101011110101000110101111100000101011101100111011001011111100000100001100010100010101101111100001110011001000011011001110001100110001001101011010001011000100011110011100000010111011010011011101110001001011011110110110000101111110010011100111100010000001001010111101110000000101110111001010110010100101010010100100011110010011110000110110011001111000110101110011011001101100101001110111111110010000001000001101011100001101111111111001011100101000011001110110001100000100101001000000110100011111001010100010110101001000111000100010010111000010000010000011011011101100100111000111001110100001111011110010010101111111100110101000001010100001011001001000101100001011000100011001011111011100100011100111011000000100110111001011001000100111111000001100010000101000000110011101011011101111111110010111011111011001010001010000101010100100111001011100111011111000011011101111110000111000101001100011001111011101000101110111111011101011000111101011001101001100101000000110110011110110001100000001100100000110011101001110100010111010101110011111010101010101000011000000101011100001110110001101001111101101101101110001111000101011100001011010010100110101111111
stdout
538