Page 1 of 3

C#

Posted: Wed Jun 20, 2012 9:52 am
by axlluis
For the ones who prefers this lenguage. I start with the first question can someone show me how to work with |N| in c# please, any funtion of c# method or something??

Re: C#

Posted: Thu Jun 21, 2012 1:55 am
by Phantom
Ok, C#, good idea, I like this language too, no many as Python and Ruby, but I like it. I can say this is the language in where I am better. If you know something about C, C++ or Java, C# will be very easy for you. C# is upswing of the languages before mentioned. If you want I teach you C#, I’ll do this. But… I recommend Python and Ruby :D.

This is an integer in C#:
int pepe = 50; //(like C, C++ and Java…)
An “int” have 32 bits, a “long” have 64, a “short” have 16, and a “bit”… (obvious)
Now is 2:00 am… another day I’ll follow. Good Nigth.
(The forum clock is bad)

Re: C#

Posted: Thu Jun 21, 2012 1:27 pm
by axlluis
Hi phantom, i need your help, in the problem "1382 - Sum of Cubes" and in others too, the result most given in mod 1000007, i dont understand what that means and how to do it in c#, i have the algorithm for the problem but i dont know how to do de mod 1000007 thing, can you help me please?

Re: C#

Posted: Thu Jun 21, 2012 5:33 pm
by Phantom
Very easy, modulus (mod) is like in almost every language:

int mod = 5 % 3; //Now mod have the value 2

mod = 13 % 5; //Now mod have the value 3

m = pq + r
The function modulus (%) returns “r”.
13 = 5*2 + 3

Re: C#

Posted: Fri Jun 22, 2012 1:08 pm
by axlluis
Thanks bro, i do what you tell me but for the last case steel give me a wrong answer, the problem is "1382 - Sum of Cubes", for the two first cases give the right answer but in the last case, give me a negative value when the right is 441. please help me with that.

Ejemplo de entrada

3
1 10
27 27
1 1000000000000000000

Ejemplo de salida

9
27
441

Re: C#

Posted: Fri Jun 22, 2012 7:43 pm
by Phantom
Your problem is not in C#. Your Problem is in your implementation. When you are adding in an integer, and in a certain moment the value of your integer is negative, is because this integer is out of range. When an integer, double, long, etc… exceed its maximum value, it take its minimum value, like a loop. In your implementation, you are not using very well the modulus operator (%) or you are not putting it in the places it must be.

Re: C#

Posted: Fri Jun 22, 2012 8:44 pm
by Robbin
May be the problem is the entry..
may be the data type is too long dor the supported by c++
I suggest you to make this program in python..or java..

Re: C#

Posted: Mon Jun 25, 2012 9:04 am
by axlluis
You have reason, my problem is not in c sharp, but i wrote in the problem set my questions and nobody answer me, and i take the chance that you help me with c sharp for make you this question.
Well, can any boy explain me what for 1 1000000000000000000 the result is 441??

Re: C#

Posted: Mon Jun 25, 2012 4:31 pm
by Phantom
Look, if you want help for your solutions, you can post in the topic "Problem set". This topic most be to talk only about C#.

Re: C#

Posted: Thu Jun 28, 2012 8:31 am
by axlluis
you are right lets talk about c-sharp so, in this code:

Code: Select all

 string[] info = Console.ReadLine().Split();
            List<int> lista = new List<int>();
            foreach (string x in info)
            {
                lista.Add(int.Parse(x));
            }
            lista.Sort();
            List<int> l_reverse = lista;
            l_reverse.Reverse(); 
Why reverse==lista, what i want is have the sort list in ascending order in "lista" and in descending order in "l_reverse", but the C# when i do " l_reverse.Reverse()" make to lista equal to l_reverse. Can someone help me?