Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Talking about whom didn’t solve anything
- Posts must be read — feedback only 5 6 people — contest notes, found same problem
- Read the statement carefully
- Solve previous contest:
- A: native solution(while), better -> if (n%5 == 0) print(n/5) : print(n/5+1)
- B: while(a<b) a*3, b*2
- a*3^n > b*2^n
- (3/2)^n > (b/a)
- n > log1.5(b/a)
- floor(
- C:
- Note that the formula n(n+1)/2 is used only for adding n consecutive integers starting from 1.
- A problem may not directly ask you for this but if you can break it down such that you have to find the sum of 'n consecutive integers starting from 1' then you can use this formula.
- In the even integers questions, you may be required to find the sum of first 10 even integers.
- 2 + 4 + 6 + ... + 18 + 20
- Take 2 common, 2*(1 + 2 + 3 + ...10)
- To find the sum of the highlighted part, we can use the formula. Then we can multiply it by 2 to get the required sum.
- Note that for odd integers, you cannot directly use this formula.
- Sum the first 10 odd integers
- 1 + 3 + 5 + 7+...+19
- But you can still make some modifications to find the sum.
- 1 + 3 + 5 + 7+...+19 = (1 +2+ 3 + 4+5 + 6+ 7+...+19 + 20) - (2 + 4+ 6+...20)
- We know how to sum consecutive integers.
- (1 +2+ 3 + 4+5 + 6+ 7+...+19 + 20) = 20*21/2
- (2 + 4+ 6+...20) = 2 * (10*11)/2 = 10*11 (as before)
- So 1 + 3 + 5 + 7+...+19 = (20*21/2) - (10*11) = 100
- ——————————————————————————————————————
- D: while loop(scan 2 number) if q-p >=2, count++
- E: sum(Xs, Ys, Zs) if equal 0,0,0 print yes otherwise print no,
- NOTE: YOU CAN’T SUM ALL OF THEM
- -1 0 1
- -1 0 1
- F: scan 3 integers and sum them, if sum>=2, count++
- G: initialise sum = 0, maxPass = 0, each scan do sum-a and sum+b, check if sum>maxPass, maxPass = sum
- H: n,h … scan n numbers, for each number check if it’s > h ans+=2, otherwise ans+=1
- J: read the problem with them, difference between lucky number and nearly lucky number, 10^18 -> long long
- ——————————————————————————————————————
- Ask for any problems
- I: for loop will time limit .. n%2 == 0, print n/2 … otherwise print -(n+1)/2
- Mention Reem’s solution, sum_even to n, sum_odd to n .. print sum_even+sum_odd
- Time complexity: 10^9 maximum
- ——————————————————————————————————————
- Arrays of integers:
- How to write it
- Practice 1: given list of numbers, print it from the last to the first
- Practice 2: Reverse the array (let them solve it)
- Array of chars:
- How to write it
- Size of the array is equal to the limit of the problem
- ‘\0’ is the termination character
- strlen(), strcmp(), strcpy(), strcat(), tolower(), toupper()
- Practice 1: loop over string and print each character
- Practice 2: print (first character, number of characters between first and last character, last character)
- ——————————————————————————————————————
- Contests Problems: (Still in progress)
- https://codeforces.com/problemset/problem/281/A
- https://codeforces.com/problemset/problem/71/A
- https://codeforces.com/problemset/problem/118/A
- https://codeforces.com/problemset/problem/112/A
- https://codeforces.com/problemset/problem/96/A
- Palindrome: https://codeforces.com/problemset/problem/798/A
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement