C,C++/JAVA/BASH/ASM ARENA

वह प्रदीप जो दीख रहा है झिलमिल दूर नही है थक कर बैठ गये क्या भाई मन्जिल दूर नही है चिन्गारी बन गयी लहू की बून्द गिरी जो पग से चमक रहे पीछे मुड देखो चरण-चिनह जगमग से बाकी होश तभी तक, जब तक जलता तूर नही है थक कर बैठ गये क्या भाई मन्जिल दूर नही है अपनी हड्डी की मशाल से हृदय चीरते तम का, सारी रात चले तुम दुख झेलते कुलिश का। एक खेय है शेष, किसी विध पार उसे कर जाओ; वह देखो, उस पार चमकता है मन्दिर प्रियतम का। आकर इतना पास फिरे, वह सच्चा शूर नहीं है; थककर बैठ गये क्या भाई! मंज़िल दूर नहीं है। दिशा दीप्त हो उठी प्राप्त कर पुण्य-प्रकाश तुम्हारा, लिखा जा चुका अनल-अक्षरों में इतिहास तुम्हारा। जिस मिट्टी ने लहू पिया, वह फूल खिलाएगी ही, अम्बर पर घन बन छाएगा ही उच्छ्वास तुम्हारा। और अधिक ले जाँच, देवता इतन क्रूर नहीं है। थककर बैठ गये क्या भाई! मंज़िल दूर नहीं है।

Comp. Sc. vs Software Engg. September 28, 2009

Filed under: Uncategorized — whoami @ 12:25

But software engineering is where the rubber meets the road. Few people care whether P equals NP just for the beauty of the question. The computer field is about doing things with computers. This means writing software to solve human problems, and running that software on real machines

Advertisements
 

TO DO List : September 24, 2009

Filed under: C,C++ Programs,Coding,JAVA — whoami @ 18:19
Tags:

SPECIAL NUMBERS(OPC practise contest Shaastra 2009)

A number is said to be special if the number of divisors it has is equal to a power of 2. For example, 6 is a special number since it has four divisors 1,2,3 and 6. A very special number is a special number whose sum of divisors is also equal to a power of 2. Given a number, print the smallest very special number that is greater than or equal to the given number.

Input:
First line of the input contains a number t, the number of test cases to follow. The next t lines each contain a number N.

Output:
Print on a new line for each test case,the smallest very special number greater than or equal to N.

Constraints:
t<5000
N<=2*10^14

Sample Input
2
23
20000000000

Sample Output
31
22545653781

Time limit: 1 second
Memory limit: 64 MB

 

I’m Scared September 23, 2009

Filed under: Literature — whoami @ 15:17
Tags:

I’m scared of ghosts that may creep up on me while I’m sleeping;
I’m scared of not having the type of life that I’ve always been dreaming;
I’m scared of always wondering what exactly that I want;
I’m scared of staying in one place doing the boring job;
I’m scared of friends coming and going like I’m some sort of motel;
I’m scared of doing the wrong thing despite my best wishes;
I’m scared of not being understood;
I’m scared of being normal;
I’m scared of not having enough time to learn;
I’m scared of being lied to;
I’m scared of sticking on something that it maybe hurt somebody;
I’m scared of doing some job only myself;
I’m scared of working hard which return a wrong answer;

 

TEST in TCL September 22, 2009

Filed under: SPOJ,TCL — whoami @ 18:00
Tags:

SPOJ Test problem in TCL language

gets stdin a
while {$a != 42} {
puts "$a"
gets stdin a
}

 

4834. Happy Sequence September 20, 2009

Filed under: C,C++ Programs,SPOJ — whoami @ 14:23
Tags:

SPOJ 4834 KZHAPPY
//my acc code on the 1st attempt, though it took time to think on how to solve it

 // ACC code
// if u remove "//" u can see the happy numbers 
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
  int n=7,k,rem,n1,j=0;
  int tmp,a[10000],cases,index;
  a[j++]=1;
  //printf("1  ");
  for(n1=7;n1<10000;n1++){
   n=n1;
   k=n;
 //n=7; 
 while(n!=1)
  {
    if(n==10||n==100||n==1000||n==10000||n==100000) {//printf("%d  ",k); 
      a[j++]=k;
      if(j>500) goto b;
    }
    
    tmp=0;
    while(n>0)
    {
      rem=n%10;
      n=n/10;
      tmp=tmp+rem*rem;
    }
    if(tmp<7) break;
    n=tmp;
  }
 
}
  b:
  scanf("%d",&cases);
  while(cases--){
   scanf("%d",&index);
   printf("%d\n",a[index-1]);
  }

return 0;
}

 

HS09BMI September 19, 2009

Filed under: C,C++ Programs,SPOJ — whoami @ 20:20
Tags:

//acc code, though rounding off digit is not optimised
HS09BMI

 #include<stdio.h>
#include<math.h>

int main()
{
 int cases, age, i,j,k;
 char ch;
 float bmi,ht,wt;
 scanf("%d\n",&cases);
 while(cases--)
 {
   scanf("%c%d%f%f\n",&ch,&age,&ht,&wt);
   if(ch=='M')
   {
     ht/=100;
     bmi=(float)(wt/(ht*ht));
     printf("%.1f",bmi);
     switch(age)
        {
          case 13 :  if(bmi<15.2||bmi>26.1)
                      printf(" WARNING");
                      break;

          case 14 :if(bmi<15.7||bmi>26.4)
                      printf(" WARNING");
                       break;
          case 15 :if(bmi<16.3||bmi>26.8)
                      printf(" WARNING");
                      break;
          case 16 :if(bmi<16.9||bmi>27.3)
                      printf(" WARNING");
                       break;
          case 17 :if(bmi<17.5||bmi>27.8)
                      printf(" WARNING");
                        break;
          case 18 :if(bmi<17.9||bmi>28.2)
                      printf(" WARNING");
                        break;
          case 19 :if(bmi<18.3||bmi>28.6)
                      printf(" WARNING");
                      break; 
         } 
         printf("\n");
    
   }
   else
    {
      if(ch=='W')
      {
        ht/=100;
        bmi=(float)(wt/(ht*ht));
        printf("%.1f",bmi);
        switch(age)
        {
          case 13 :  if(bmi<15.4||bmi>25.4)
                      printf(" WARNING");
                      break;

          case 14 :if(bmi<16.0||bmi>26.3)
                      printf(" WARNING");
                      break;
          case 15 :if(bmi<16.6||bmi>26.8)
                      printf(" WARNING");
                      break;
          case 16 :if(bmi<16.9||bmi>27.2)
                      printf(" WARNING");
                      break;
          case 17 :if(bmi<17.2||bmi>27.3)
                      printf(" WARNING");
                       break;
          case 18 :if(bmi<17.39||bmi>27.4)
                      printf(" WARNING");
                       break;
          case 19 :if(bmi<17.5||bmi>27.4)
                      printf(" WARNING");
                        break;
           } 

        printf("\n");

      
      }
    

    }//else
  }//while

return 0;
}

 

SPOJ 4830. KZWC

Filed under: C,C++ Programs,SPOJ — whoami @ 20:04

//acc on the day of post of the prob.
SPOJ 4830. KZWC

 #include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
  char c,s[100];
  int cases,n,tot,year,i,k;
  scanf("%d",&cases);
  
  while(cases--)
  {
   scanf("%d ",&year);
   gets(s);
   tot=0;
   //while((c=getchar())!='\n')
   i=0;
    while(s[i]!=NULL)
    {
      c=s[i];
      i++;
      k=0;
     switch(c)
     {
        case 'A':
                  if(year>2005){k=1; n=year-2005;}else if(year>=2001){k=1; n=year-2001;}
                  break;
        case 'B':
                  if(year>2006){k=1; n=year-2006;}else if(year>=2002){k=1; n=year-2002;}
                  break;
        case 'C':
                  if(year>2007){k=1; n=year-2007;}else if(year>=2003){k=1; n=year-2003;}
                   break; 
         case 'D':
                  if(year>2008){k=1; n=year-2008;}else if(year>=2004){k=1; n=year-2004;}
                   break;

        case 'E':
                  if(year>2009){k=1; n=year-2009;}else if(year>=2005){k=1; n=year-2005;}
                   break;

        case 'F':
                  if(year>2010){k=1; n=year-2010;}else if(year>=2006){k=1; n=year-2006;}
                   break;

        case 'G':
                  if(year>2011){k=1; n=year-2011;}else if(year>=2007){k=1; n=year-2007;}
                   break;

     }//end of case
 
        if(k==1)
        tot=tot+n*n;
       


  }//inner while
    printf("%d\n",tot);
}//outer while

return 0;
}