c++(0ms 100%) iteratively and math (with comments)
we understand that : if our last digit in our number K is 0.2.4.5.6.8 we will answer -1(this obviously )\n 2. in other case we understand that we always have an
1. we understand that : if our last digit in our number K is 0.2.4.5.6.8 we will answer -1(this obviously )\n 2. in other case we understand that we always have answer and that answer we can image as sequense of digit 1(N). what we say about our number N ? first - we absolutelly understand that number will have common divider with our number K. second - but our number N we can  imagine as sum, where sum we can transform into this : 1 * first_digit + 10 * second_digit + 100 * third_digit and so etc. third - if our N have common divider consecuently our sum have too. and we can apply **chinese remainder theorem.** \n3. we will summarize our remainders and check sum%K if we have 0, we have answer.\n4. we can have next remainder if we multiply previous remainder and 10 and take mod from that number and K\n\n\n```\nclass Solution {\npublic:\n    int smallestRepunitDivByK(int K) {\n      if(K%2 == 0 || K%5 == 0) return -1;\n      int rez = 1;                           //number of digits 1 in our answer\n      int remainder = 1;               //first remainder\n      int total = 1;                        // summe of our remainders\n      while(total%K != 0){\n        rez++;\n        remainder = (remainder*10)%K;\n        total = (total + remainder)%K;\n      }\n      return rez;\n    }\n};\n```\n\n**or such :**\n```\nclass Solution {\npublic:\n  int smallestRepunitDivByK(int K) {\n    if(K%2 == 0 || K%5 == 0) return -1;\n    int rez = 1, rem = 1, tot = 1;                           \n    for(;tot%K != 0 ; rez++, rem = rem*10%K,tot = (tot + rem)%K);\n    return rez;\n  }\n};\n```\n**or such :**\n```\nclass Solution {\npublic:\n  int smallestRepunitDivByK(int K) {\n    int a = 1;                           \n    for(int r = 1, t = 1; t%K != 0 && a <= K; a++, t += (r = r*10%K));\n    return a > K ? -1 : a;\n  }\n};\n```
['C', 'C++']