You are not logged in. Please login at www.codechef.com to post your questions!

×

How to include the Constraints

eg: 1 ≤ T ≤ 7

1 ≤ |S| ≤ 10^5

asked 26 Feb '15, 16:24

champ9's gravatar image

2★champ9
11
accept rate: 0%

Please specify what you actually want us to help you with.

(26 Feb '15, 18:17) arun_as1★

If you are asking on how to include these constrains in your code, then let me tell you that constrains are more like tips here, they tell you how big values might be and so that you can adjust your data types to hold those values ( like you need to use long for large numbers and long long for even larger numbers like for example, for 1 ≤ T ≤ 10^13, you will need long long int, a simple int will not be enough ). You don't need to check for those constrains in your code, the values will always be within the constrains.

Let us consider your case

1 ≤ T ≤ 7

It means that the value for T entered during your program run on codechef will be >= 1 and <= 7.

And

1 ≤ |S| ≤ 10^5

Probably means that the length of S will be >= 1 and <= 10^5.

Hope this is what you were asking for in your question. :)

link

answered 26 Feb '15, 18:25

arun_as's gravatar image

1★arun_as
7413618
accept rate: 10%

edited 26 Feb '15, 18:38

make the program such that it passes the constraints , for eg- if 1<=n<=10^18 int variables wont work, you would have to use long long int. I hope that solves yr query

link

answered 26 Feb '15, 18:25

pra1nay7_313's gravatar image

2★pra1nay7_313
111
accept rate: 0%

You do not need to include the constraints. Constraints are given to check the approximate Order of the algorithm that can pass the problem.

You do not need to explicitly check the constraints in your solution.

Hope it Helps!!!

Happy Coding

link

answered 26 Feb '15, 18:27

the65bit's gravatar image

4★the65bit
1.1k101328
accept rate: 13%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×31

question asked: 26 Feb '15, 16:24

question was seen: 5,600 times

last updated: 26 Feb '15, 18:38