checkMate09's blog

By checkMate09, history, 8 years ago, In English

Hello Codeforces.

Recently I was solving (UVA-10490) [perfect numbers] that I found tackling the problem knowing an interesting mathematical fact would make it very very simple unlike if you don't know this fact. so I thought it would be useful to gather some interesting mathematical numbers and it would be very kind of anyone to share an mathematical formula, facts, numbers that can help in tackling such problems.

1) Narcissistic Numbers

Narcissistic numbers, also known as Armstrong numbers or “pluperfect digital invariants,” are numbers that—listen closely—are equal to the sum of each of its digits when those digits are raised to the power of the AMOUNT of digits in the number.Ok. What? Let’s take an example of the four existing narcissistic cubes:153 = 1^3 + 5^3 + 3^3 370 = 3^3 + 7^3 + 0^3 371 = 3^3 + 7^3 + 1^3 407 = 4^3 + 0^3 + 7^3In these cases, each digit is cubed because there are three digits in the number. Then, those cubed numbers are added together to produce a sum equal to the original number. There are no 12 or 13-digit ones; the two 39-digit ones are:115132219018763992565095597973971522400 and 115132219018763992565095597973971522401.

2) Happy Numbers

Some numbers are weird; others are happy. If you’d like to find out if a given number is happy, you’ll need to perform the following set of operations. Let’s take the number 44:First, square each digit, then add them together:4^2 + 4^2 = 16 + 16 = 32Then, we’ll do it again with our new number:3^2 + 2^2 = 9 + 4 = 13And again:1^2 + 3^2 = 1 + 9 = 10And finally:1^2 + 0^2 = 1 + 0 = 1Voila! It’s a happy number. Anytime you take a number, perform this “procedure,” and eventually arrive at the number 1, you have yourself a happy number. If your number never reaches 1, then sadly, it’s unhappy. Interestingly, happy number are extremely common; there are 11 of them between 1 and 50, for example.As a final note, the greatest happy number with no recurring digits is 986,543,210. That is a happy number indeed.

3) Perfect Numbers

perfect numbers. A perfect number is one that is exactly equal to the sum of its proper divisors (again, excluding itself). The first perfect number is 6, as its divisors (1, 2, 3) all up to 6. Six is followed by 28, 496, and 8,128. Early Greek mathematicians knew only of these first 4 perfect numbers; Nichomatus discovered 8,128 by the year A.D. 100. Three more were discovered, the first circa 1456 (33,550,336) by an unknown mathematician, and in 1588 (8,589,869,056 and 137,438,691,328) by Italian mathematician Pietro Cataldi in 1588.All known perfect numbers are even; it is not yet known whether an odd prime exists or is even possible. English mathematician James Joseph Sylvester wrote “…a prolonged meditation on the subject has satisfied me that the existence of any one such [odd perfect number]—its escape, so to say, from the complex web of conditions which hem it in on all sides—would be little short of a miracle.”

4) Untouchable Numbers

For a number to be untouchable, it must not be equal to the sum of the proper divisors of ANY number. A few untouchables are 2, 5, 52, and 88; in fact, 5 is thought to be the only odd untouchable number in existence (though it hasn’t been formally proven). There are an infinite number of untouchable numbers, meaning there is no such thing as the largest one.

5) Smith Numbers

A Smith number is a composite number for which, in a given base (in base 10 by default), the sum of its digits is equal to the sum of the digits in its prime factorization.For example, 378 = 2 × 3 × 3 × 3 × 7 is a Smith number since 3 + 7 + 8 = 2 + 3 + 3 + 3 + 7. In this definition the factors are treated as digits: for example, 22 factors to 2 × 11 and yields three digits: 2, 1, 1. Therefore 22 is a Smith number because 2 + 2 = 2 + 1 + 1.

The first few Smith numbers are:

4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517,526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985

6)Carmichael Numbers

In number theory, a Carmichael number is a composite number n which satisfies the modular arithmetic congruence relation: b^(n-1) = 1 (mod n).

the first few of them :561, 1105, 1729, 2465, 2821, 6601, 8911, 10585, 15841, 29341, 41041, 46657, 52633, 62745, 63973, 75361, 101101, 115921, 126217, 162401, 172081, 188461, 252601, 278545, 294409, 314821, 334153, 340561, 399001, 410041, 449065, 488881, 512461.

resources :

http://listverse.com/2013/05/15/10-fun-examples-of-recreational-number-theory/

https://en.wikipedia.org/wiki/Smith_number

https://en.wikipedia.org/wiki/Carmichael_number

note : the contributions will be added to the blog time by time.

Thanks . :)

Full text and comments »

  • Vote: I like it
  • +42
  • Vote: I do not like it

By checkMate09, history, 8 years ago, In English

Hello,

Is there any specific procedures to be followed in order to use file streams in Eclipse C/C++ IDE because the following code doesn't output to the file unlike Codeblocks did , any clue ?

Code : http://pastebin.com/juSDxhMm

Thanks :)

Full text and comments »

  • Vote: I like it
  • +6
  • Vote: I do not like it

By checkMate09, history, 8 years ago, In English

Hello All,

a)Where can I find solutions to the problem on E-Olymp ?

b)How good is practicing on the problems there for ACM-ICPC Preparation ?

c)any advice before going through the problems there ?

Full text and comments »

  • Vote: I like it
  • +2
  • Vote: I do not like it

By checkMate09, history, 8 years ago, In English

hey ,

the problem link : http://www.spoj.com/problems/MMOD29/

i can't figure how to get the divisors of a number that i won't able to store in any data type and i can't think in any path of the problem which i think it's a well-know technique or something like that

any help , thanks :)

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By checkMate09, history, 8 years ago, In English

Hi,

today, while solving problems i faced a problem that the output is printed only when i terminate the program i deleted the project created another one with the same problem.

do any one know how to solve this matter ?

thanks.

Full text and comments »

  • Vote: I like it
  • +6
  • Vote: I do not like it

By checkMate09, history, 8 years ago, In English

Hello codeforces,

when i was solving some problem i noticed that there is something unusual with the layout of the codeforces running in google chrome and i can't surf it normally with the disappear of the right toolbar , any help to fix it ?!

Full text and comments »

  • Vote: I like it
  • -12
  • Vote: I do not like it

By checkMate09, history, 8 years ago, In English

Hello Codeforces,

I spent last 3 days trying to solve TOUR problem.

every time i send, it it gives me run time error although i changed the whole code and the idea !

my idea is simple as to check that there is only 1 source ssc in the graph then printing it's size.

here is my code : http://pastebin.com/vsWrCKeL

can any one help me with that run time error judgment ?

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By checkMate09, history, 8 years ago, In English

Hello Codeforces,

I've asked a question related to Tarjan's algorithm of finding SCC at Quora since a while with a lot of people want the answer as well as i sake can any one help us ?

https://www.quora.com/How-does-Tarjans-SCC-algorithm-work?__snid3__=356797187&__nsrc__=2&__filter__

Full text and comments »

  • Vote: I like it
  • +5
  • Vote: I do not like it

By checkMate09, history, 8 years ago, In English

Hi Codeforces,
As far As we seen in the last rated Codeforces round as well as the educational one problems C
C. Pythagorean Triples
C. Magic Odd Square
can be solved by searching on google for common formulas or algorithms and solve them.
so I'm asking about the importance of this paradigm of problems in ACM contests or in general competitive programming.

Full text and comments »

  • Vote: I like it
  • -8
  • Vote: I do not like it

By checkMate09, history, 8 years ago, In English

i was coding solution for the problem C. The Smallest String Concatenation . the solution depends mainly on overriding the cmp() function. first version caused RTE

bool cmp(const string &a, const string &b){

    return a+b <= b+a;
}

second version Accepted without = sign.

bool cmp(const string &a, const string &b){

    return a+b < b+a;
}

why the = sign caused RTE ?

UPD : RTE submission http://codeforces.me/contest/632/submission/20033016

Full text and comments »

  • Vote: I like it
  • +12
  • Vote: I do not like it

By checkMate09, history, 8 years ago, In English

Hello code forces,

i'm trying to put a short time plan to practice for a period of nearly 1 month , but i'm confused about where should i practice in solving problems. A)the gym. B) regular round. so what is the major difference of problems in gym compared to those in regular round ?

Full text and comments »

  • Vote: I like it
  • +1
  • Vote: I do not like it

By checkMate09, history, 8 years ago, In English

Hello Codeforces, i have tried to understand Edit Distance Dynamic Programming classical problem and i tried few tutorials through the internet and i couldn't understand the concept. can any one clarify it to me in very simple way ?

Full text and comments »

  • Vote: I like it
  • -7
  • Vote: I do not like it

By checkMate09, history, 8 years ago, In English

Hello Codeforces, Recently i face a problem that when a problem is judged wrong answer i can't wait to detect the wronged the test case by my self and i use the jury's answers. a) what is the time u spend on detecting the wronged answer by your self ? b) average time before u use the tutorial of the problem ? Thanks , :)

Full text and comments »

  • Vote: I like it
  • +13
  • Vote: I do not like it

By checkMate09, history, 8 years ago, In English

Hey codeforces , I was solving C. Replacement. my first submission got Accepted with awful time 1996 ms -> My first Submission
so i was looking to reduce it once using cin.tie and it doesn't work cin.tie(0) submission another way that i tried is to use scanf instead of cin and the code didn't output even sample answers correctly. and here is the strangest thing that i re-send the accepted code it gives TLE now!! so, any coding technique to reduce the time? why is my cin.tie submission Run time error? why my identical accepted submission got TLE ? Thanks.

Full text and comments »

  • Vote: I like it
  • -5
  • Vote: I do not like it

By checkMate09, history, 9 years ago, In English

it's weird ! after participating virtually, i can't see other's submissions or test cases of problems..

Full text and comments »

  • Vote: I like it
  • -1
  • Vote: I do not like it

By checkMate09, history, 9 years ago, In English

here is my code for problem C. Booking System code : http://pastebin.com/RjPfn3uU when i test at Custom test for the case of every variable = 1000 it gives me (Run time error: exit code is 3)!.. any one faced same verdict before ?

Edit : maybe the very long test case caused some people to dislike the blog and not to help so i removed it

Full text and comments »

  • Vote: I like it
  • -17
  • Vote: I do not like it

By checkMate09, history, 9 years ago, In English

in problem B. Well-known Numbers Codeforces Round 139 Div 2 The K-bonacci numbers are only 0 and powers of two. how is the output of the first sample 3 0 2 3 although the sum is equal to s 3 isn't belong to any term of bonacci sequence. how is this possible ?

Full text and comments »

  • Vote: I like it
  • +10
  • Vote: I do not like it