Sort by

recency

|

287 Discussions

|

  • + 0 comments

    include

    include

    include

    include

    include

    include

    include

    include

    include

    include

    char* readline(); char* ltrim(char*); char* rtrim(char*);

    int main() { int t; // Number of test cases scanf("%d", &t);

    while (t > 0) {
        long int k;
        scanf("%ld", &k);
        if(k%2==0)
        {
           long int i = k / 2 ; // Divide by 2 and store as double
         // Convert to integer by truncating decimal part
         long int j = k - i; // Remaining cuts for the other dimension
    
        // Calculate maximum pieces as a product of integers
        long int maxPieces = i * j;
    
        printf("%ld\n", maxPieces); // Print result as integer
        }
    
        else {
         long double i = ( long double)k / 2 + 0.5; // Divide by 2 and store as double
         // Convert to integer by truncating decimal part
        long double j = k - i; // Remaining cuts for the other dimension
    
        // Calculate maximum pieces as a product of integers
       long int maxPieces = i * j;
    
        printf("%ld\n", maxPieces); // Print result as integer}
        }
        t--;
    
    }
    return 0;
    

    }

  • + 0 comments

    Haskell

    module Main where
    
    import Control.Monad (replicateM_)
    
    main :: IO ()
    main = do
        cases <- readLn :: IO Int
        replicateM_ cases $ do
            n <- readLn :: IO Integer
            let (q, r) = n `quotRem` 2
            print $ q * (q + r)
    
  • + 0 comments
    (k//2) * ((k+1)//2)
    
  • + 0 comments
    def halloweenParty(k):
        return math.ceil(k/2)*(k-math.ceil(k/2))
    
  • + 0 comments

    Python

    def halloweenParty(k):
        return (k//2)*(k-k//2)