Friday, 9 March 2018

13A-Numbers.... Simple, yet logical

Ref : http://codeforces.com/problemset/problem/13/A

Here, the nr and dr can be found easily, but they can be factored out by some number....
That's the tricky thing !!!
Happy Coding and stay *HUMBLE*

TLE jz for using printf() instead of putchar()

Exact same logic,but jz i used printf everywhere,but when i changed em to putchar(), BOOM
it's AC !!!!
left side - AC
right side - TLE

Also note that among two accepted codes,
1 is 62 ms
and other is 92 ms
HEED !!!

Wednesday, 7 March 2018

Hell yeah !!! A day long 1B- Spreadsheet

1B-spreadsheet

Ref : http://codeforces.com/problemset/problem/1/B

First, I didnt get AC jz coz  of some mysterious unknow off-by one error i can say...!
Here's my unaccepted code : 
while(C > 0){
                int x = 0;
                x = (C-1)%26;
                if(x == 0){
                 ans[i++] = 'Z';
                }
                else{
                    ans[i++] = 'A'+x-1;
                }
                C = (C-1)/26;
            }

Actually, I found that my logic is wrong :/
But when  I changed it to this, It got accepted : 

while((C-1)/26){
ans[i++] = (C-1)%26+'A';
C = (C-1)/26;
}
ans[i++] = (C-1)%26+'A';

Monday, 5 March 2018

O(1) : No.of perfect squares between given range

Source : quora >>>
https://www.quora.com/How-can-I-find-out-number-of-perfect-squares-in-a-given-range-of-numbers-in-c-c++-programming-in-least-time

Formula : 1 + (floor (sqrt (upper bound) ) - (ceiling ( sqrt (lower bound) )


I'm loving it ...... !!!!