🌐
Codeforces
codeforces.com › blog › entry › 109514
Ceil and floor functions in C++ without using std::ceil or std::floor - Codeforces
One of my friends advised me to use this formula to find the ceil(a, b) $$$\lceil \frac{a}{b} \rceil = \frac{a + b - 1}{b}$$$ so in code : int ceil = (a + b - 1) / b; this works perfectly fine with positive $$$a/b$$$ But unfortunately, this ...
🌐
Codeforces
codeforces.com › blog › entry › 82642
Floor and Ceiling - Codeforces
2) Pallove · Blog · Teams · ... 3 years ago, Tips and Tricks by Pallove · Floor : int x,y; int ans = Floor(x/y) = x/y; Ceiling : int x,y; int ans = Ceiling(x/y) = (x + y - 1)/y; floor division, ceiling, floor, #tips ...
🌐
Codeforces
codeforces.com › blog › entry › 78852
Alternative approaches to ceil() - Codeforces
int a = 3; int b = 2; cout << ceil(a/b) ... quotient a/b is in int and the decimal values are discarded (floored). a/b = 1 so ceil(a/b) = ceil(1) = 1....
🌐
Codeforces
codeforces.com › contest › 2082 › problem › B
Problem - B - Codeforces
Ecrade will perform exactly $$$n$$$ first operations and $$$m$$$ second operations in any order. He wants to know the minimum and the maximum possible value of $$$x$$$ after $$$n+m$$$ operations.
🌐
Codeforces
codeforces.com › group › MWSDmqGsZm › contest › 219158 › problem › H
Problem - H - Codeforces
Floor: Is a mathematical function that takes a real number $$$X$$$ and its output is the greatest integer less than or equal to $$$X$$$. Ceil: Is a mathematical function that takes a real number $$$X$$$ and its output is the smallest integer ...
🌐
Codeforces
codeforces.com › blog › entry › 52345
Notes on Codeforces Beta Round #49, A, B(Trick to avoid using floor and ceil functions), C, D - Codeforces
Then, we also transform the original constraints into ... Therefore, floor(b*X)=s*X/t, where the '/' in s*X/t is an "integer division" operation. For p*X/q, if (p*X)%q==0, we can directly use p*X/q as the lower bound, where '/' in p*X/q is an ...
🌐
Codeforces
codeforces.com › problemset › problem › 2082 › B
Problem - 2082B - Codeforces
For each test case, print two integers in one line, representing the minimum and the maximum possible value of $$$x$$$ after $$$n + m$$$ operations.
🌐
Codeforces
codeforces.com › blog › entry › 113633
[Tutorial] Floors, ceilings and inequalities for beginners (with some programming tips) - Codeforces
cry → Codeforces Round 993 (Div. 4) a1akashchauhan → Is Practice the only way to improve rating? PeruvianCartel → I reached GM, this is insane! (sequel to my previous post) pwned → Train Better with ThemeCPs (+ Website)! programmer5777 → What it SBT? nor · Blog · Teams · Submissions · Groups · Contests · [Tutorial] Floors, ceilings and inequalities for beginners (with some programming tips) By nor, 21 month(s) ago, https://nor-blog.codeberg.page/posts/2023-03-07-floors-ceilings-inequalities-for-beginners/ +211 ·
🌐
Codeforces
codeforces.com › blog › entry › 112174
Quick question about floor and ceiling when dividing in an inequality - Codeforces
Ekber_Ekber → Create codeforces round. bonavara → Judges is lagging · lenamphong03122012 → What is 403 Forbidden? emptyhope → UOJ Long Round #3: 60h Challenge · SuperSheep · Blog · Teams · Submissions · Contests · Quick question about floor and ceiling when dividing in an inequality ·
🌐
Codeforces
codeforces.com › blog › entry › 140702
Codeforces Round 1010 (Div. 1, Div. 2, based on Zhili Cup 2025) Editorial - Codeforces
This demonstrates that performing $$$n$$$ floor operations first followed by $$$m$$$ ceil operations will always yield the maximum value. Similarly, performing $$$m$$$ ceil operations first followed by $$$n$$$ floor operations will always produce ...
Find elsewhere
🌐
Codeforces
codeforces.com › problemset › problem › 1469 › D
Problem - 1469D - Codeforces
D. Ceil Divisions ... You have an array $$$a_1, a_2, \dots, a_n$$$ where $$$a_i = i$$$. In one step, you can choose two indices $$$x$$$ and $$$y$$$ ($$$x \neq y$$$) and set $$$a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$$$ (ceiling function).
🌐
Codeforces
codeforces.com › blog › entry › 113259
ceil(A/B) < C closed form - Codeforces
caiyingqi_01 → I want to report a atcoder user in codeforces · bhawnapannu2701 → Request for Clarification – Disabled Account [bhawnapannu27] codern_org → Technology Olympics 2025 (Algorithms & Data) – 4 days remaining ... My solution was using binary search. However, the official solution came up with this clever closed form formula: ... I'm completely boggled by this equation. I've seen quite a few closed form equations involving floor and ceil ...
🌐
Codeforces
codeforces.com › blog › entry › 94178
Dealing with inbuilt ceil function c++ - Codeforces
CarViz → codeforces... we need to talk ... I was having trouble while using ceil function in c++, I would like to explain the mistake I was making by example ... the mistake here is that I am dividing 5 by 2 in int type so it returns 2 and ceil function won't do anything as 2 is already an integer number, whereas in float type division 5/2.0 will give 2.5 which will be converted into 3 by ceil function.
🌐
Codeforces
codeforces.com › blog › entry › 21691
The ceil trap (Beginners Only Topics) - Codeforces
awoo → Educational Codeforces Round 148 [Rated for Div. 2] ... I fell into a very interesting situation today , while solving CF — 599D. ... I wrote long long c = ceil(a*1.0/b) thinking (long * double) / double should be perfect double and ceil(double) — should work out.
🌐
Codeforces
codeforces.com › blog › entry › 107717
PSA: don't use these functions unless you really, really need to - Codeforces
They are designed to be used with a floating-point input and a floating-point output. The issue is that on a floating-point number, the result may not be exact. Worse, floating-point numbers may not be able to accurately encode the integer. Don't use floor((double) a / (double) b) or similar. Do use a / b. It will round down. Warning: be careful with negative numbers. The answer depends on whether we should round down or towards 0. Don't use ceil...
🌐
Reddit
reddit.com › r/cpp_questions › looking for a kind soul to assist with 'floor' and 'ceil' in c++
r/cpp_questions on Reddit: Looking for a kind soul to assist with 'floor' and 'ceil' in C++
December 12, 2022 -

Soooo, I am very green/new to any type of code and programming. I understand the base concept of the floor/ceil. Functions but unsure how to incorporate them to my current code. I can give brief details of deliverables. Prompt user to input 2 values to be converted from Celsius to Fahrenheit. Determine which of the 2 is the "start/stop" values. Once start and stop are determine, the program converts every value in the range input from user to Fahrenheit, in 1 degree increments.

I have all of the code complete.. my issue is floor and ceil functions just won't round up or down as expected. Not proficient enough to determine where my code needs to be tweaked. Please help. Thank you. The "start" value should round down and the stop value should round up. My code either rounds both up or down.

Willing to elaborate more if the above doesnt make sense.. with anyone willing to help.

🌐
Medium
medium.com › @Harshit_Raj_14 › codeforces-round-893-div-2-my-editorial-bb01b5b340a0
Codeforces Round 893 (Div. 2) — My Editorial | by Harshit Raj | Medium
August 17, 2023 - import java.util.*; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t--> 0) { int a = sc.nextInt(); //pressed by Anna only int b = sc.nextInt(); //pressed by Katie only int c = sc.nextInt(); //can be pressed by either a+=Math.ceil(c/2.0); b+=Math.floor(c/2.0); if(a>b) System.out.println("First"); else System.out.println("Second"); } sc.close(); } } ... Instead we use a+=Math.ceil(c/2.0); Because we want to do float division and then find its ceil or floor.
🌐
GitHub
github.com › tar3q-az1z › Codeforces-solutions › blob › main › 1475A.cpp
Codeforces-solutions/1475A.cpp at main · tar3q-az1z/Codeforces-solutions
if(ceil(log2(n))==floor(log2(n))){ flag=0; } else{ printf("YES\n"); flag=1; } } · · if(flag==0){ printf("NO\n"); } ·
Author   tar3q-az1z