Блог пользователя Son_Nguyen

Автор Son_Nguyen, история, 9 лет назад, По-английски

Hello, I have a problem need to solve:

S(n) = 1^k + 2^k +..+n^k

input: n<=10^9, k<=40

output: S(n)%(10^9+7).

One more issue:

how to calculate ((n^k)/x)%p which very big n and k.

Thank for helping me.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +7
  • Проголосовать: не нравится

Автор Son_Nguyen, история, 9 лет назад, По-английски

Hello everybody. That is my code to show binary a decimal number. It's right when a>=0 but when a<0 that can't work, infinite loop. And I don't know what wrong in this code. Can you help me to solve? Thank so much!

void bi(int a)
{
        if(a==0)
            return;
        bi(a>>1);
        cout<<(a & (1));
}

//I have a nother code and it's right in both case. However I want to know what happen with this code. Sorry for my bad English

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор Son_Nguyen, 10 лет назад, По-английски

Hello everybody, my English not good, I wish many people can understand what I wrote :D You know "|" and "||" are meaning "or", "&" and "&&" are meaning "and" then what is difference ? Look at this code

int a = 0,b = 1;
if(b||a++);
cout<<a;

output: 0

int a = 0,b = 1;
if(b|a++);
cout<<a;

output: 1 I don't know why but I think || and && is smart, in this example when b==1 (true) then b "or" something is true, so "||" don't care after if sentese true in anyway. And "&&" is the same,

int a = 0,b = 1;
if(a && b++);
cout<<b;
int a = 0,b = 1;
if(a & b++);
cout<<b;

let try and see :). That is my second blog, My first blog is very bad, I wish this blog is better, sorry because my english is very bad. Thank for reading !

Полный текст и комментарии »

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится