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

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

D.O.P.E Online Judge! prob:-Modulus February 28, 2010

Filed under: C,C++ Programs,Programming Contest — whoami @ 10:16
Tags: ,

D.O.P.E Online Judge! prob:-Modulus

–AC–

#include
int main()
{
long long int a,b,res,tmp,i,j,k,c;
for(k=0;k<10;k++){

scanf("%lld%lld%lld",&a,&b,&c);
res=a%c;
res=(res*b)%c;

printf("%lld\n",res);
}
return 0;
}

 

D.O.P.E Online Judge! prob:-Complement February 28, 2010

Filed under: C,C++ Programs — whoami @ 09:48
Tags: ,

D.O.P.E Online Judge! prob:-Complement

–AC–

#include<stdio.h>
int main(){long long n,t,b,c;while(1){if(scanf("%lld",&n)==-1) break;
t=n;c=0;while(1){t>>=1;if(t==0) break;++c;}c+=1;n=~n;b=0;b=~b;b<<=c;
b=~b;n=n&b;printf("%lld\n",n);}return 0;}

 

SPOJ UBoat Problem code: HS09UBT February 28, 2010

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

SPOJ UBoat
Problem code: HS09UBT

–AC–

 

SPOJ Problem Set (first) 2980. ATM Problem code: HS08TES February 27, 2010

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

SPOJ Problem Set (first)
2980. ATM
Problem code: HS08TES

–AC–

#include<stdio.h>
int main()
{
  int i,j,k;
  int X;
  float Y,amt,tmp;
  scanf("%d%f",&X,&Y);
  
  if(X%5==0&&(Y-0.50)>=(float)X)
   amt=Y-(float)X-0.50;
  else
   amt=Y;
  
  printf("%.2f\n",amt);

return 0;
}

 

SPOJ Bridge Building Problem code: HS09BRI February 27, 2010

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

SPOJ Bridge Building
Problem code: HS09BRI

--AC–[10 points]

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

int main()
{
  int i,j,k;
  int a,b,c,h;
  float x,y,z;
  float aa,bb,cc,hh,min;
  scanf("%d%d%d%d",&a,&b,&c,&h);
  aa=a;bb=b;cc=c;hh=h;
   min=10000000;
  for(x=0;x<=cc;x=x+1){
   y=sqrtf(aa*aa+(cc-x)*(cc-x))+hh+sqrtf(bb*bb+x*x);
   if(y<min)
    min=y; 
  }
 printf("%.2f\n",min);

return 0;
}

 

SPOJ 6192. H Function February 25, 2010

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

SPOJ 6192 H Function
Problem code: HFUN

–AC–

T,N;main(){scanf("%d",&T);while(T--){scanf("%d",&N);N=(!N)?1:(N<3)?N:(N<5)?6:(N<6)?3:9;
printf("%d\n",N);}exit(0);}

 

TJU 1365. Hard to Believe, but True! February 25, 2010

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

TJU 1365. Hard to Believe, but True!

–AC–

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
  char sa[10],sb[10],sc[10];
  int i,j,k,la,lb,lc,a,b,sum;
  char c;
  while(1){
  i=0;
  while(1){ c=getchar(); if(c=='+') break;sa[i++]=c;}
  sa[i]='\0';
  i=0;
  while(1){ c=getchar();if(c=='=') break;sb[i++]=c;}
  sb[i]='\0';
  i=0;
  while(1){ c=getchar();if(c=='\n') break;sc[i++]=c;}
  sc[i]='\0';
  la=strlen(sa);lb=strlen(sb);lc=strlen(sc);
  for(i=0;i<la/2;i++){
    c=sa[i];sa[i]=sa[la-1-i];sa[la-1-i]=c;
   }
   for(i=0;i<lb/2;i++){
    c=sb[i];sb[i]=sb[lb-1-i];sb[lb-1-i]=c;
   }
   for(i=0;i<lc/2;i++){
    c=sc[i];sc[i]=sc[lc-1-i];sc[lc-1-i]=c;
   }
   a=atoi(sa);b=atoi(sb);sum=atoi(sc);
   if(a==0&&b==0&&sum==0) {printf("True\n");break;}
   if((a+b)==sum) printf("True\n");
   else printf("False\n");
   }

return 0;
}

 

SPOJ 6125. Dos Date February 21, 2010

Filed under: C,C++ Programs,Challenge,SPOJ — whoami @ 22:56
Tags: , ,

SPOJ 6125. Dos Date(challenge)
Problem code: DDATE

—AC—

j,k,N,X,l,y,d,m,r;*o[]={"January","February","March","April","May","June","July","August","September","October","November","December"};
main(){scanf("%d",&N); while(N--){scanf("%d",&X);j=k=l=d=m=y=0;while(X){r=X%2;(j<5)? (d+=r*pow(2,j++)):(k<4)?(m+=r*pow(2,k++)):(y+=r*pow(2,l++));    X/=2;}printf("%d %s %d\n",d,o[m-1],y);}exit(0);}

 

SPOJ 3378. Mirrored Pairs February 21, 2010

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

SPOJ 3378. Mirrored Pairs
Problem code: MIRRORED

—AC–

 

SPOJ 5842. Polybius square February 18, 2010

Filed under: C,C++ Programs,Challenge,SPOJ — whoami @ 19:51
Tags: ,

challenge:
5842. Polybius square
Problem code: POLYBIUS

c,i,j,k,l;main(){char s[1000];scanf("%d\n",&c);while(c--){gets(s);for(i=0;s[i];i++){if(s[i]!=32){if(s[i]<73){j=s[i]-65;}if(s[i]>72){if(s[i]==73)s[i]=74;j=s[i]-66;}k=j/5+1;l=j%5+1;printf("%d%d ",k,l);}}puts("");}exit(0);} 

 

CodeCraft 2010 February 14, 2010

Filed under: C,C++ Programs,CodeCraft,TODOLIST — whoami @ 15:39
Tags: , ,

Temperature
TODOLIST

 

TopCoder SRM -185 PassinGrade February 14, 2010

Filed under: C,C++ Programs,SRM,Top Coder,TOPCODER — whoami @ 11:05
Tags: , ,

TopCoder SRM -185 PassinGrade

–[sumbit with 143.52/250]

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
using namespace std;

class PassingGrade{
 
 public:
    int pointsNeeded( vector<int>  pointsEarned,vector<int>pointsPossible,int finalExam){
       float r1=0,r2=0,per=0.0;
       int i,j;
       for(i=0;i<pointsEarned.size();i++){
           r1+=pointsEarned[i];
           r2+=pointsPossible[i];
       }
        r2=r2+finalExam;
        per=(r2*65)/100;
        //cout<<per<<endl;
        float need=per-r1+0.5;
        i=need;
        //cout<<i; 
        if(i>finalExam) return -1;
        else return i;
     }

};

/*
int main()
{
  PassingGrade pg;
   int myints1[] = { 1, 2, 3, 4 };
  vector<int> v1 (myints1, myints1 + sizeof(myints1) / sizeof(int) );
  //vector<int> v1;
   int myints2[] = { 2, 3, 4, 5};
  vector<int> v2 (myints2, myints2 + sizeof(myints2) / sizeof(int) );
  //vector<int> v2;
  int n=pg.pointsNeeded(v1,v2,7);
   cout<<n<<endl;

return 0;
}

*/       
 



 

TopCoder Member SRM 461 -TrappingRabbits February 13, 2010

Filed under: C,C++ Programs,Top Coder,TOPCODER — whoami @ 18:45
Tags: , ,

Problem is below:
–SUBMIT[158/250 pointts]–

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
using namespace std;

class TrappingRabbit{
    int min,j;
    public:
       int findMinimumTime(vector<int> trapX,vector<int> trapY){
          min=99999999;
          for(int i=0;i<trapX.size();i++){
             j=trapX[i]-1+trapY[i]-1;
             if(min>j)
               min=j;
          }

          return min;
        }
};

/*
int main()
{
  TrappingRabbit tr;
   int myints1[] = {4,6,8};
  vector<int> v1 (myints1, myints1 + sizeof(myints1) / sizeof(int) );
  //vector<int> v1;
   int myints2[] = {1,2,1};
  vector<int> v2 (myints2, myints2 + sizeof(myints2) / sizeof(int) );
  //vector<int> v2;
  int n=tr.findMinimumTime(v1,v2);
   cout<<n<<endl;

return 0;
}
*/

Problem:
(more…)

 

TopCoder SRM 147 Div2 February 13, 2010

Filed under: C,C++ Programs,OOPS,Top Coder,TOPCODER — whoami @ 10:21
Tags: , ,

TopCoder SRM 147 Div2
C++
–SUBMITTED–[149 points]

#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
using namespace std;

class CCipher{

   public:
       string decode(string cipherText,int shift){
         for(int i=0;cipherText[i]!='\0';i++)
            cipherText[i]='A'+(cipherText[i]-'A'+26-shift)%26;
          return cipherText;
        }
};

/*int main()
{
 CCipher c;
 string s=c.decode("VQREQFGT",2);
 cout<<s<<endl;

return 0;
}
*/

 

Proving running times -Algorithms February 12, 2010

Filed under: Algo & Data Structure — whoami @ 22:18
Tags:

(more…)

 

 
Follow

Get every new post delivered to your Inbox.