552A  Vanya and Table For each rectangle she adds ,the value of all the cells in that rectangle is increased by one. Hence it is obvious that if a rectangle of side n*m is added ,the ans increases by n*m
for each rectangle
scan(x1)
scan(y1)
scan(x2)
scan(y1)
ans=ans+(x2x1+1)*(y2y+11)
Time Complexity O(n)
My submission:: 11637017
552B  Vanya and Books By number of digits the question means the total number of digits.
Hence number of digits for 1=1
number of digits for 10=2
number of digits for 100=3
We need to write all numbers from 1n We find the number of digits in n (lets call it k).
Ans=(the number of digits in all 1 digit numbers)+(number of digits in all 2 digit numbers)+...(number of digits in all k1 digit numbers)+number of digits from 10^k to n.
As the number of p digit numbers = 9*pow(10,p1)
for(i from 1 to k1)
 ans=ans+i*(9*pow(10,k1))
And finally ans=ans+(npow(10,k1)+1)*k
My submission: O(log(n))
My submission :11639835
552C  Vanya and Scales The problem is a simple case of recursion.We have weights of the form w^k(0<k<100).
if there exists a combination of weights that forms the mass M , then
M=summation(w^k1)summation(w*k2)
Hence M has to be of the form w*t+k (1<=k<=1)
t also has to be of the form w*t1+k1 (1<=k1<=1)
Hence the recursion continues . The base case is when t<w.The answer will be yes if t=w1t=1t=0
Time Complexity O(log(M))
My submission:11644642
The problem can be solved by a simple brute force for all the points in pairs of 3.If the area of a given pair of 3 triangles is not zero , then it is a possible triangle.
 for(i from 0,n1)

 for(j from i,n1)


 for(k from j,n1)




 if (area (i,j,k)!=0)





 ans++;


Time Complexity O(n^3)
The problem can however be solved in n^2 complexity.By iterating over all points in pairs of 2 , we can store their slopes in a map.
Then on iterating over the map we can find the number of triangles which wont contribute to the answer.
for(it in map)
 k += (it*(it1)*(it2)/6)
answer=n*(n1)*(n2)/6k
Time Complexity O(n^2*log(n))
My submission: 11727314
An easy analysis shows that the brackets must be placed adjacent to * sign since they wont have any effect next to a + sign.
We need to store the indexes of all the * in the string and iterate over all possible pairs. One thing to keep in mind is the maximum case may be one in which the brackets starts at the 0th index or the one in which it ends at the last index.
Time Complexity O((length of string)*15*15)
My submission: 11726590
Auto comment: topic has been updated by hsk (previous revision, new revision, compare).
Let's begin
first solution is wrong . it shoudl be (x2x1+1) similarly y . eg (1,1 )(3,3 ) = (31+1) *(31+1)=9 While you will give ans as (31 ) * (31)=4
you shouldnt use pow func. Make your own function instead
4th . the complexity you get using map is (n^2 log(n) )
My bad...Will edit
Well pow() function can be made error free just by using ceil(pow(a,b).. Well it has always worked for me.. :)
EDITED