BidMag

Tuesday, August 20, 2019

Codeforces Solution 71A || Codeforces Solution Way Too Long Words

In this section , I am gonna give you the source code of the codeforces solution of the problem 71A  Way Too Long Words.
Problem Name: Way Too Long Words
Online Judge: Codeforces.com
The below given code is written in C language. :

  1. #include<stdio.h>
  2. #include<ctype.h>
  3. int main(){
  4. int n,i,m;
  5. char x[6000];
  6. scanf("%d",&n);
  7. for(i=1;i<=n;i++){
  8. scanf("%s",&x);
  9. int l=strlen(x);
  10.  
  11. if(l>10){
  12.  
  13. printf("%c",x[0]);
  14. printf("%d",l-2);
  15. printf("%c\n",x[l-1]);
  16.  
  17. }
  18. else printf("%s\n",x);}
  19. return 0;
  20. }



In python (basically Python 3) Language , the solution should be :

  1. i=input
  2. for _ in [0]*int(i()):
  3. s=i();l=len(s)-2;print([s,s[0]+str(l)+s[-1]][l>8])




Tuesday, August 7, 2018

Codeforces Problems Solution 226A - Stones on the Table

Hi friends, I am going to post the solve of the problem '226A - Stones on the Table' of Codeforces.
The problem screenshots is given below:

Code:

Codeforces Problems' Solution (339A - Helpful Maths)




The solution of the problem is given below:


#include <stdio.h>
#include <string.h>
int main ()
{
      char s[1000];
      int i, j = 0, k, l, ln, arr[1000], m, n, temp;
      scanf("%s", s);
      ln = strlen(s);
      for(i = 0; i < ln; i++)
      {
          if((i % 2) == 0)
          {
              arr[j] = (int) s[i];
              j++;
          }
      }
      for(m = 1; m < j; m++)
     {
          for(n = 0; n < (j - m); n++)
         {
              if(arr[n] > arr[n + 1])
              {
                  temp = arr[n];
                  arr[n] = arr[n + 1];
                  arr[n + 1] = temp;
              }
          }
      }
      for(k = 0; k < j; k++)
      {
          if(k == (j - 1))
          {
              printf("%c", (char) arr[k]);
          }
          else
          {
              printf("%c%c", (char) arr[k], '+');
          }
      }
      printf("\n");

      return 0;
}


Monday, August 6, 2018

Codeforces Solution of 112A - Petya and Strings in C

Hi friends, I am going to post the solve of the problem '112A - Petya and Strings' of Codeforces.
The problem screenshot is given below:


Code:

Codeforces Solutions- 96A Football

Hi friends, In this post I am gonna give you the solution of the codeforces problem: 96A - Football.
The problem screenshot is given below:


Solutions Of Codeforces Problem- A Bit++ in C language

Problem screenshot is given Below:



Code:

Codeforces Problems' Solution (122A - Lucky Division) in C