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

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

kill any process Forcibly in Unix March 18, 2010

Filed under: fedora,LINUX,Top Coder,TOPCODER — whoami @ 19:18
Tags: , , ,

Often it happens that some programs hangs and it doesnot close by clicking the “X ” button.In that case we can use “$kill ” command to kill the process.”$Kill” has several options attached with it. To kill something forcibly we use “-9” option. I show u some example.
——————
step1:->
$ps -a
-> this will list all process (but not that which runs in the background)
$ps -e
->this will list all process , evem those that runs in the background

—————————————
step2->
Now that we have listed the process by above two methods, chose the “pid” of that process which u want to kill
$kill “pidnumber”
->where pidnumber is the one u noted from above which u want to stop.
**this may not kill some process. So for this use -9 option
$kill -9 “pidnumber”
-> now ur required process will be closed
———————————–
Actually sometimes while using TopCoder Arena, the applet didnot closes or it Hangs, To stop it either i has to restart the system or i had to log off and then log in. Now through theses commnads with -9 option i can close it.
sample:->

[abc@localhost ~]$ ps 
  PID TTY          TIME CMD
 3564 pts/0    00:00:00 bash
 3857 pts/0    00:00:00 ps
[abc@localhost ~]$ ps -a
  PID TTY          TIME CMD
 3858 pts/0    00:00:00 ps
[abc@localhost ~]$ ps -e
  PID TTY          TIME CMD
    1 ?        00:00:00 init
    2 ?        00:00:00 kthreadd
    3 ?        00:00:00 migration/0
    4 ?        00:00:00 ksoftirqd/0
    5 ?        00:00:00 watchdog/0
    6 ?        00:00:00 migration/1
    7 ?        00:00:00 ksoftirqd/1
    8 ?        00:00:00 watchdog/1
    9 ?        00:00:01 events/0
   10 ?        00:00:00 events/1
   11 ?        00:00:00 cpuset
   12 ?        00:00:00 khelper
   13 ?        00:00:00 netns
   14 ?        00:00:00 async/mgr
   15 ?        00:00:00 kintegrityd/0
   16 ?        00:00:00 kintegrityd/1
   17 ?        00:00:00 kblockd/0
   18 ?        00:00:00 kblockd/1
   19 ?        00:00:00 kacpid
   20 ?        00:00:00 kacpi_notify
   21 ?        00:00:00 ata/0
   22 ?        00:00:00 ata/1
   23 ?        00:00:00 ata_aux
   24 ?        00:00:00 ksuspend_usbd
   25 ?        00:00:00 khubd
   26 ?        00:00:00 kseriod
   27 ?        00:00:00 khungtaskd
   28 ?        00:00:00 pdflush
   29 ?        00:00:00 pdflush
   30 ?        00:00:00 kswapd0
   31 ?        00:00:00 aio/0
   32 ?        00:00:00 aio/1
   33 ?        00:00:00 crypto/0
   34 ?        00:00:00 crypto/1
   40 ?        00:00:00 scsi_eh_0
   41 ?        00:00:00 scsi_eh_1
   43 ?        00:00:00 kpsmoused
   44 ?        00:00:00 kstriped
   45 ?        00:00:00 ksnapd
   46 ?        00:00:00 usbhid_resumer
   69 ?        00:00:00 kdmflush
   70 ?        00:00:00 kdmflush
   71 ?        00:00:00 kjournald2
   80 ?        00:00:00 kauditd
  158 ?        00:00:00 udevd
  776 ?        00:00:00 kmmcd
  795 ?        00:00:00 tifm
  863 ?        00:01:23 phy0
  894 ?        00:00:00 pccardd
  989 ?        00:00:00 hd-audio0
 1063 ?        00:00:00 kmpathd/0
 1064 ?        00:00:00 kmpathd/1
 1065 ?        00:00:00 kmpath_handlerd
1093 ?        00:00:00 kjournald
 1179 ?        00:00:00 kondemand/0
 1180 ?        00:00:00 kondemand/1
 1212 ?        00:00:00 auditd
 1214 ?        00:00:00 audispd
 1215 ?        00:00:00 sedispatch
 1239 ?        00:00:00 rsyslogd
 1262 ?        00:00:00 rpcbind
 1281 ?        00:00:03 dbus-daemon
 1291 ?        00:00:00 avahi-daemon
 1292 ?        00:00:00 avahi-daemon
 1301 ?        00:00:00 cupsd
 1322 ?        00:00:00 acpid
 1330 ?        00:00:01 hald
 1333 ?        00:00:00 console-kit-dae
 1334 ?        00:00:00 hald-runner
 1424 ?        00:00:04 hald-addon-inpu
 1442 ?        00:00:00 hald-addon-gene
 1458 ?        00:00:00 hald-addon-cpuf
 1459 ?        00:00:00 hald-addon-acpi
 1475 ?        00:00:00 pcscd
 1489 ?        00:00:00 NetworkManager
 1495 ?        00:00:00 nm-system-setti
 1499 ?        00:00:00 wpa_supplicant
 1507 ?        00:00:00 rpc.statd
 1533 ?        00:00:00 rpciod/0
 1536 ?        00:00:00 rpciod/1
 1543 ?        00:00:00 rpc.idmapd
 1551 ?        00:00:00 bluetoothd
 1565 ?        00:00:00 bluetooth
 1578 ?        00:00:00 sshd
 1618 ?        00:00:00 gpm
 1629 ?        00:00:00 crond
 1640 ?        00:00:00 atd
 1648 ?        00:00:00 gdm-binary
 1649 tty4     00:00:00 mingetty
 1650 tty5     00:00:00 mingetty
 1651 tty2     00:00:00 mingetty
 1652 tty3     00:00:00 mingetty
 1653 tty6     00:00:00 mingetty
 1694 ?        00:00:00 gdm-simple-slav
 1695 tty1     00:05:29 Xorg
 1724 ?        00:00:00 dbus-launch
 1772 ?        00:00:00 sendmail
 1773 ?        00:00:00 sendmail
 1840 ?        00:00:01 devkit-power-da
 1842 ?        00:00:00 devkit-daemon
 1895 ?        00:00:00 gdm-session-wor
 1920 ?        00:00:00 gnome-keyring-d
 1934 ?        00:00:00 gnome-session
 1949 ?        00:00:00 dbus-launch
 1951 ?        00:00:00 dbus-daemon
 2032 ?        00:00:02 gconfd-2
 2037 ?        00:00:00 gnome-settings-
 2050 ?        00:00:04 metacity
 2055 ?        00:00:24 pulseaudio
 2056 ?        00:00:02 gnome-panel
 2059 ?        00:00:00 gconf-helper
 2061 ?        00:00:00 gvfsd
 2073 ?        00:00:00 gvfs-fuse-daemo
 2077 ?        00:00:02 nautilus
 2079 ?        00:00:00 bonobo-activati
 2084 ?        00:00:00 seapplet
 2085 ?        00:00:00 nm-applet
 2086 ?        00:00:00 bluetooth-apple
 2090 ?        00:00:00 python
 2091 ?        00:00:00 notification-da
 2093 ?        00:00:00 gnome-volume-co
 2096 ?        00:00:00 im-settings-dae
 2098 ?        00:00:00 kerneloops-appl
 2105 ?        00:00:01 gpk-update-icon
 2116 ?        00:00:01 gnome-power-man
 2129 ?        00:00:02 kerneloops
 2314 ?        00:00:00 gconf-im-settin
 2348 ?        00:00:00 gvfsd-trash
 2351 ?        00:00:00 gvfs-gdu-volume
 2353 ?        00:00:01 devkit-disks-da
 2354 ?        00:00:00 devkit-disks-da
 2364 ?        00:00:00 trashapplet
 2365 ?        00:00:03 wnck-applet
 2368 ?        00:00:00 gvfs-gphoto2-vo
 2373 ?        00:00:01 clock-applet
 2377 ?        00:00:01 tomboy
 2378 ?        00:00:00 notification-ar
 2380 ?        00:00:00 gdm-user-switch
 2388 ?        00:00:00 gvfsd-burn
 2398 ?        00:00:00 run-mozilla.sh
 2413 ?        00:04:51 firefox
 2432 ?        00:00:01 gnome-screensav
 2753 ?        00:00:02 gedit
 3562 ?        00:00:00 gnome-terminal
 3563 ?        00:00:00 gnome-pty-helpe
 3564 pts/0    00:00:00 bash
 3718 ?        00:00:01 javaws ->this is TopCoder application running
 3763 ?        00:00:18 javaws->--do--
 3860 pts/0    00:00:00 ps
[abc@localhost ~]$ kill -9 3718
[abc@localhost ~]$ kill -9 3763
[abc@localhost ~]$ kill -9 2413
[abc@localhost ~]$ ps -e


Advertisements
 

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

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;
}
*/

 

TopCoder Arena launching in fedora(linux) February 12, 2010

Filed under: C++ Programs,OOPS,TOPCODER — whoami @ 20:10
Tags:

Today i launched Topcoder arena in feodra. To do this just save the tocoderapplet file and then open it with firefox and then enter option …/../jawas which is located in java folder or jre folder of java……………

Now i will start doing problems over here also. One important thing about topcoder is that it doesnot use ” main ” function .However method has to be defined public.

TopCoder!!!!!!!!!!!!!