this is the program for http://www.codechef.com/problems/MARCHA4/
Anil


On Sun, Mar 7, 2010 at 3:15 PM, Anil C R <[email protected]> wrote:

> ahh... yes I see..
>
> Anil
>
>
>
> On Sun, Mar 7, 2010 at 3:12 PM, Rohit Saraf 
> <[email protected]>wrote:
>
>> i guess it's C# , some microsoft language (i don't like microsoft
>> languages)
>> -Rohit
>>
>>
>>
>> On Sun, Mar 7, 2010 at 3:09 PM, Anil C R <[email protected]> wrote:
>>
>>> is this some dialect of C++?
>>>
>>> Anil
>>>
>>>
>>>
>>> On Sun, Mar 7, 2010 at 3:08 PM, Rohit Saraf <[email protected]
>>> > wrote:
>>>
>>>> It's difficult and boring(:P) to go through the code...
>>>> better give ur logic..
>>>>
>>>> -Rohit
>>>>
>>>>
>>>>
>>>> On Sun, Mar 7, 2010 at 3:04 PM, B |_ /\ C |<--D ! /\ /\/\ O /\| D <
>>>> [email protected]> wrote:
>>>>
>>>>> /**** this is the problem of finding first K and last k of N^N but i am
>>>>> failling somewhere what's wrong thing am i doing
>>>>> using System;
>>>>> namespace MyProgram
>>>>> {
>>>>>     class PowerUpperDown
>>>>>     {
>>>>>         string zero = "000000000";
>>>>>         const long Mod = 10000000000;
>>>>>  //calculate the a^x
>>>>>         long pow(long a, long x)
>>>>>         {
>>>>>             if (x == 0)
>>>>>                 return 1;
>>>>>             if (a == 0) return 0;
>>>>>             long ans = pow(a, x / 2);
>>>>>             ans = (ans * ans) % Mod;
>>>>>             if (x % 2 == 0)
>>>>>                 return ans;
>>>>>             else return (ans * a) % Mod;
>>>>>         }
>>>>> //print last k digit
>>>>>         public string printL(long X, int k, long Max)
>>>>>         {
>>>>>             string str = X.ToString();
>>>>>             string output = "";
>>>>>             int C = (int)Math.Min(k, Max);
>>>>>             if (X == 0)
>>>>>                 output = zero.Substring(0, C);
>>>>>             else
>>>>>             {
>>>>>                 if (str.Length < C)
>>>>>                     output = zero.Substring(0, C - str.Length) + str;
>>>>>                 else
>>>>>                 {
>>>>>
>>>>>                     output += str.Substring(str.Length - C, C);
>>>>>                 }
>>>>>             }
>>>>>             return output;
>>>>>         }
>>>>>         //first k digit
>>>>>         public string printF(long X, int k, long Max)
>>>>>         {
>>>>>             string output = X.ToString();
>>>>>             int C = (int)Math.Min(k, Max);
>>>>>             return output.Substring(0, C);
>>>>>         }
>>>>>         public static void Main(string[] argv)
>>>>>         {
>>>>>             int T = Int32.Parse(Console.ReadLine());
>>>>>             PowerUpperDown mypowerobj = new PowerUpperDown();
>>>>>             for (int cases = 0; cases < T; cases++)
>>>>>             {
>>>>>                 string[] input = Console.ReadLine().Split(' ');
>>>>>                 long N = Int64.Parse(input[0]);
>>>>>                 int K = Int32.Parse(input[1]);
>>>>>                 double fract = N * Math.Log10(N);
>>>>>                 long M = (long)fract;
>>>>>                 fract = fract - M;
>>>>>                 M++;
>>>>>                 if (N < 10)
>>>>>                 {
>>>>>                     long val = mypowerobj.pow(N, N);
>>>>>                     Console.WriteLine(mypowerobj.printF(val, K, M) + "
>>>>> " + mypowerobj.printL(val, K, M));
>>>>>                 }
>>>>>                 else
>>>>>                 {
>>>>>                     long val1 = (long)(Math.Pow(10, fract) * Mod);
>>>>>                     long val2 = mypowerobj.pow(N, N);
>>>>>                     Console.WriteLine(mypowerobj.printF(val1, K, M) + "
>>>>> " + mypowerobj.printL(val2, K, M));
>>>>>                 }
>>>>>             }
>>>>>         }
>>>>>     }
>>>>> }
>>>>>
>>>>>
>>>>>  --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Algorithm Geeks" group.
>>>>> To post to this group, send email to [email protected].
>>>>> To unsubscribe from this group, send email to
>>>>> [email protected]<algogeeks%[email protected]>
>>>>> .
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>
>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to [email protected].
>>>> To unsubscribe from this group, send email to
>>>> [email protected]<algogeeks%[email protected]>
>>>> .
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected]<algogeeks%[email protected]>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected]<algogeeks%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to