How? Can you explain a little bit?DJWS wrote:You can solve this problem with the Divide and Conquer approach.
Search found 26 matches
- Mon Jun 09, 2008 1:53 pm
- Forum: Volume 101 (10100-10199)
- Topic: 10101 - Bangla Numbers
- Replies: 122
- Views: 45430
Re: 10101 - Bangla Numbers
- Sun Jun 08, 2008 2:17 pm
- Forum: Volume 101 (10100-10199)
- Topic: 10101 - Bangla Numbers
- Replies: 122
- Views: 45430
Re: 10101 - Bangla Numbers
Here's how I solve the problem not using hard code
1. Use "/" and "%" to extract one or two integer(s) from the input and use an integer array of size 9 to store them
As the max number is 999999999999999, which is 15 digits, the max size the input number can be divided is 9, according to the sample ...
1. Use "/" and "%" to extract one or two integer(s) from the input and use an integer array of size 9 to store them
As the max number is 999999999999999, which is 15 digits, the max size the input number can be divided is 9, according to the sample ...
- Fri May 30, 2008 6:06 pm
- Forum: Volume 106 (10600-10699)
- Topic: 10673 - Play with Floor and Ceil
- Replies: 11
- Views: 8025
Re: 10673 - Play with Floor and Ceil
Solved, I think the most difficult part is to find the relationship between k,p and q using the modular
- Fri May 30, 2008 10:43 am
- Forum: Volume 4 (400-499)
- Topic: 488 - Triangle Wave
- Replies: 270
- Views: 64374
Re: 488 TLE
Finally got AC, thanks
But I want to know why the following can make my program run faster:
1. What's the difference between "endl" and "\n"?
2. What's the difference between "cin and cout" and "scanf and printf"?
3. Why "cin.sync_with_stdio(false);" and "cout.sync_with_stdio(false);" can make my ...
But I want to know why the following can make my program run faster:
1. What's the difference between "endl" and "\n"?
2. What's the difference between "cin and cout" and "scanf and printf"?
3. Why "cin.sync_with_stdio(false);" and "cout.sync_with_stdio(false);" can make my ...
- Fri May 30, 2008 10:27 am
- Forum: Volume 106 (10600-10699)
- Topic: 10673 - Play with Floor and Ceil
- Replies: 11
- Views: 8025
Re:
You can simply separate this problem into two cases and discuss each of them: "k divides x" and "k does not divide x." BTW, you can also think about the modular. Modular is somehow related to the floor and the ceil function.
This problem can be solved by very simple formula instead of the extended ...
This problem can be solved by very simple formula instead of the extended ...
- Thu May 29, 2008 1:43 pm
- Forum: Volume 106 (10600-10699)
- Topic: 10673 - Play with Floor and Ceil
- Replies: 11
- Views: 8025
Re: 10673 - Play with Floor and Ceil
After I got wrong answers for 2 times, I search for google for some info and discover that those symbols are not brackets
I misunderstood that the "floor" and "ceil" are brackets at first
There are functions called floor and ceil in the math library in C++ which represent round down and round up ...
I misunderstood that the "floor" and "ceil" are brackets at first
There are functions called floor and ceil in the math library in C++ which represent round down and round up ...
- Thu May 29, 2008 1:25 pm
- Forum: Volume 106 (10600-10699)
- Topic: 10673 - Play with Floor and Ceil
- Replies: 11
- Views: 8025
Re: 10673 - Play with Floor and Ceil
By solving the formula
x = p (x/k) + q (x/k)
x = (p+q) / k * x
(p+q) / k = 1
p+q = k
Sample input:
3
5 2
40 2
24444 6
Sample output:
1 1 <-- 1+1=2
1 1 <-- 1+1=2
0 6 <-- 0+6=6
But I have submitted for 2 times using different methods and both are wrong answer, I don't know why, can anyone ...
x = p (x/k) + q (x/k)
x = (p+q) / k * x
(p+q) / k = 1
p+q = k
Sample input:
3
5 2
40 2
24444 6
Sample output:
1 1 <-- 1+1=2
1 1 <-- 1+1=2
0 6 <-- 0+6=6
But I have submitted for 2 times using different methods and both are wrong answer, I don't know why, can anyone ...
- Thu May 29, 2008 7:46 am
- Forum: Volume 2 (200-299)
- Topic: 272 - TEX Quotes
- Replies: 136
- Views: 56441
Re: 272 -WA-Plz help to debug it!!!
At last, I got AC, totally 7 tries, THANKS for everyone who has helped me b4
SPECIALLY THANKS for the AC of "dreadlord", it helps me to find out what's the differences between a AC and mine and debug
I discovered that the trick is using,
while(getline(cin,s,'\0'))
then the program will keep input ...
SPECIALLY THANKS for the AC of "dreadlord", it helps me to find out what's the differences between a AC and mine and debug
I discovered that the trick is using,
while(getline(cin,s,'\0'))
then the program will keep input ...
- Thu May 29, 2008 7:09 am
- Forum: Volume 2 (200-299)
- Topic: 272 - TEX Quotes
- Replies: 136
- Views: 56441
Re: 272 -WA-Plz help to debug it!!!
I've tried to move the code used on file back to console mode, but wrong answer still occurs, why?
I know how to use the "<<" and ">>", they are used to tell me where does the output start and where it ends. Is my WA related to "|" or anything else?
Removed after AC
I know how to use the "<<" and ">>", they are used to tell me where does the output start and where it ends. Is my WA related to "|" or anything else?
Removed after AC
- Thu May 29, 2008 6:52 am
- Forum: Volume 2 (200-299)
- Topic: 272 - TEX Quotes
- Replies: 136
- Views: 56441
Re: 272 -WA-Plz help to debug it!!!
Finally, I can produce the correct input with a text file, but I don't know how to move back to the console, pls give me a help
Code: Select all
Removed after AC
- Wed May 28, 2008 1:50 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10062 - Tell me the frequencies!
- Replies: 235
- Views: 69482
Re: 10062 - Tell Me the Frequencies!
This part will be just under gets()
if(counter != 0)
cout << endl;
counter = 1;
I finally figure out what's wrong with the blank line, those blank lines make my submission WA AGAIN and AGAIN, I finally got accepted, thank a lot
P.S. The correct ouput should be like this
AAABBC
67 1
66 2
65 3 ...
if(counter != 0)
cout << endl;
counter = 1;
I finally figure out what's wrong with the blank line, those blank lines make my submission WA AGAIN and AGAIN, I finally got accepted, thank a lot
P.S. The correct ouput should be like this
AAABBC
67 1
66 2
65 3 ...
- Wed May 28, 2008 1:12 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10062 - Tell me the frequencies!
- Replies: 235
- Views: 69482
Re: 10062 - Tell Me the Frequencies!
Check the output producing system I gave above and print that way.
I got accepted by editing this so why you won't get. :o
Change the line
cout << endl;
into:
int count =0; <<--at the starting of the program, (before while)
if(count!=0) cout << endl;
count =1;
I follow your method to change ...
I got accepted by editing this so why you won't get. :o
Change the line
cout << endl;
into:
int count =0; <<--at the starting of the program, (before while)
if(count!=0) cout << endl;
count =1;
I follow your method to change ...
- Wed May 28, 2008 1:03 pm
- Forum: Volume 2 (200-299)
- Topic: 272 - TEX Quotes
- Replies: 136
- Views: 56441
Re: 272 -WA-Plz help to debug it!!!
Actually the most important thing I don't understand is that there are 2 versions of AC
One claims that just replace all " with `` and ' ' and you can get AC,
but another saying is that spaces and newlines have to be considered too
Which one is correct?
One claims that just replace all " with `` and ' ' and you can get AC,
but another saying is that spaces and newlines have to be considered too
Which one is correct?
- Wed May 28, 2008 12:59 pm
- Forum: Volume 2 (200-299)
- Topic: 272 - TEX Quotes
- Replies: 136
- Views: 56441
Re: 272 -WA-Plz help to debug it!!!
Where should the below code added and what's the purpose?
I know how to output the spaces but I still don't manage to output line by line, I can just output a single continuous line, what else should I add?
I know how to output the spaces but I still don't manage to output line by line, I can just output a single continuous line, what else should I add?
Code: Select all
cout << "<<" << s << ">>";
- Wed May 28, 2008 12:54 pm
- Forum: Volume 4 (400-499)
- Topic: 488 - Triangle Wave
- Replies: 270
- Views: 64374
Re: 488 TLE
Those cin and cout are slow function.
Remove them and use printf and scanf.
The version you sent me also uses cin and cout, it's a AC, right?
Mine is not just only exceeded for a few seconds, but at least 5 - 10s, coz I keep refreshing firefox and the status keep "running" until TLE appears.
Then ...
Remove them and use printf and scanf.
The version you sent me also uses cin and cout, it's a AC, right?
Mine is not just only exceeded for a few seconds, but at least 5 - 10s, coz I keep refreshing firefox and the status keep "running" until TLE appears.
Then ...