Привет!
Не получается решить эту задачу. Вот мой код:
#include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
int ans = 0;
for (int i = 0; i < a; i++) ans++;
for (int i = 0; i < b; i++) ans++;
cout << ans << endl;
return 0;
}
Помогите
Ну явно мало плюсов в коде.
Аж 8, куда же больше?
Ой, я отправил, а оно прошло. Наверное, админ тимуса после этого поста нашёл баг и исправил его.
A simple 3D segment tree does the job.
I think the judge should have problem I tried segment tree but couldn't accept.
It took me 4D segment tree to solve this. How did you solve it with 3D :o ?
Egor please don't cry :(
You can solve it by using Z-rule or Pythagoran theorem.
424 .Record?
Not yet
but yet (over 450)
Not yet
EDIT: Now it is! Congratulations!
Sorry. Double post
Not yet
Not yet
I did the same thing. Got 13 WA bcoz of '<' instead of '<=' on line 2374. Finally AC!!! :)
change the ints to long long and it will pass i guarantee it !!! says this with thumbs up
Серые да зелёные повылазили...
А я почему-то верю в автора. Нутром чую — у него большое будущее.
Вспомните потом мои слова — не пройдет и двух недель, как он станет красным.
Хм, а предсказание-то постепенно сбывается. Еще недавно он был серым, а сейчас уже синий...
фиолетовый! Хотя я не помню ни одного контеста за эти дни. И когда он качаться успевает? Сразу видно — талант!
UPD: уже оранжевый! И что удивительно — опять не было ни одного контеста.
Look, you are a newbie. This world of Codeforces is really very tough for newbies. Sorry to say that :(
Work hard. You will succeed here. Though it is gonna be tough. :P
Надо через динамику по маскам решать, там намного проще! в крайнем случае — декартка
Капитан Очевидность сообщает, что нужно отправлять не exeшник, а cppшник
I think you should read my new book: How to Get 2700+ Rating on Codeforces in 10 Days
You must read this :)
Damn it. It is just "Use +" in Russian, and I used 8 of them
You must read this :)
ugh newbies these days....
theres an easier way to do this
Not compiled!
Go drunk , you're home...
Так версия Java не та, это же 7, а ты наверно под 8 сабмитил
Egor it seems that you need to make training like cgy4ever
I expect you will be better in the near future I discovered a lot of guys but this time really I believe that you someday will be good and I'm sure you will be red.
anyway If you need any kind of help in any hard problems just tell me.
I will make training soon for some Beginners if you are interested you can join :P
I want to join to.
Do you grantee to get a good result after 10 days?
;;)
after training two days you become Green, Congrats
My solution also gives TLE, I think I should try memoization:
I like your sense of humor, Egor. It sure makes me laugh (although I am a poor newbie as well :P)
Indeed, it's a tough problem for your level. I think it can be solved by defining the addition operation through Lambda Calculus.
First, let's define Natural Numbers. Let's say that a number x is a function that given another function y and a variable z, applies y on z for x times.
0 ::== λx.λy.z
1 ::== λx.λy.x y
2 ::== λx.λy.x x y
...
So, let's define the addition operator. It would simply be:
add a b ::== a λx.λy.x b x y (Remember: a, b are natural numbers, so they are just functions.)
I'll leave the easy work of handling negative numbers, thinking about how to relate that to code, .. etc, to you as a kind of practice.
One last note: I really didn't try to learn these things, so I'm probably speaking nonsense. But a newbie like you wouldn't tell.
I have this problem: http://www.spoj.com/problems/TEST
I'm thinking about an approach using Suffix Tree, Splay Tree, Dynamic convex hull, Max flow using pre-flow push with global heuristic. But I still don't have any good solution. Can anyone help me please :(
Poor ! You could have done it with Heavy Light Decomposition. :p
Uff these newbies are always irritating us international grandmaster ( I always wanted yo say this ) :D
Y u so cocky!:)
Performed poorly in last contest :( straight newbie from international grandmaster :(
Let IGM help you :)
Magical suggestion: You need practice a lot of practice to apply these complicated things. Sometimes programming is tough, but don't lose heart and keep practicing :) Upsolving is important too.
I submitted your code with out any changes but get compilation error. :|
It's so hard for you to solve this problem... :|
You should practice hard to do that... :|
Once mathlover told me this problem can be solved by using network flow. I think the approach newbie mathlover told us can be understood easily by us poor newbies.
Interesting... I really enjoy this problem but since I am only an expert, I am looking forward to opinions from these explosions of International Grandmasters, (I honestly don't know how).
Your code runs in linear time, with a constant factor of one. The constant factor however can be reduced to half with two simple base cases by doing the following:
int main() { int a, b; cin >> a >> b; int ans = 0; if (a == 1) { cout << b + 1 << endl; } else { cout << a + 1 << endl; } for (int i = 0; i < a; i += 2) ans += 2; for (int i = 0; i < b; i += 2) ans += 2; cout << ans << endl; return 0; }
It requires complex bit manipulation.
So, I think it might be too tough for your level. First work on easier problems and build your level up to this.
Anyway, here is my AC solution for your reference.
Your solution is O(a+b) which is quite slow , you can use a technique similar to Exponentiation by squaring so it will become O(log(a)+log(b)), also it's better if you use fast input/output methods
here's the code
Your algorithm is O(a+b). You can easily make it O(min(a,b)). Here is how to do it:
Also, you should use faster IO methods.
It's also provable that O(a+b) and O(min(a,b)) are both the same thing, but this requires some deep analysis. For the problem, it's a classic application of FFT. Maybe you may want to chose an easier problem to get you started.
Я так и не решил :( мой профиль
Используй какой-нибудь компилятор C++, под паскалем работать не будет.
riadwaw знает о чем говорит.
Did you try to solve it for small a and b? It must be a pattern there, and then precalc does the matter.
The answer is trivial . 1- Swap a and b
2- find the largest a*b digit prime that can be expressed only by powers of 2 ;) eg 7 = 2^3 — 2^0
3- Now multiply that prime number by a|b
4- print a+b
I have been searching for a solution to this problem for over a year.. And today I found a solution thanks to google. However it was too complicated and I couldnt prove it. Please help, heres the code:
What does this '+' magical symbol does?
This code uses a special greedy algorithm that fails for large cases; In that case we must build complex data structure (the code is too long for me to post here) to fix it.
But i tried to submit it. It got accepted
yes probably test cases are weak to promote hacks
No no. You're wrong. You should solve it in a clear recursively way like this:
Also be sure to use
to not be time limit exceeded while getting the input. :)
*I suggest you first of all learn functions and then try to solve a+b problem. Because it needs recursive functions...
I getted compail errer with youre code.
Do youre code is rially collect? Pleeze fix me:)
Oh! Thanks for reminding me!
Pay attention to this point:
You should notice you can add two values recursively only with C++. In other languages, it is much more harder!
Ничего эти серые не умеют.
Не "Не могу решить задачу", а "Нимагу ришит зодачю", не "Помогите" а "Памагити". Код тоже не надо писать — нужно требовать, чтобы его кто-нибудь вместо тебя написал.
Но ты же сам серый :(
Ну я и говорю, ничего эти серые не умеют.
your code is too complicated to understand . as a newbie coder i suggest you to follow the way you actually do computation in mind . how do you add in mind ? obviously by memorizing the last state. so here is the best thing for newbies :D
Egor Lol :P
del
congrats karan :D
lol ayush :P :P jokes apart,i have a lot to learn :)
You have the best rating I've ever seen(1001 !! That's great!!) Seriously, why do you want to be red??
I guess we have some misunderstandings here.
I wasn't joking in my last comment... I LOVE palindromes and 1001 is the first non-obvious palindrome number! (Contains even number of digits and has at least two different digits.) From my point of view, it's one of the best ratings! :)
there is my code for this problem, it works for 1<=a,b <=1000
RGHOST
MEGA
i will try to type code solving for constraints up to 10000!
I think the hint is misleading, you shouldn't use '+'. This code gets AC and has no '+' at all:
But yours much easier to understand
You're asked to use the
+
operator. This is why I think the following link may be useful:http://stackoverflow.com/a/19412942
You may need to make a few insignificant changes if this program wouldn't strictly conform to the required input specification.
I watched some lectures about randomized algorithms from Burunduk1 recently, and i tried his usual recipe — as everybody knows, it works for every problem...
Chuck Norris can get AC with this code
Watch
Wow such an elegant solution!
You just forgot to shuffle the input.
Same problem here
it took 2 hrs of coding but nothing at the end :(
I'll keep trying, I'll teach you if i got accepted
It is easy to guarantee constant time lookup:
I think you can easily see how to extend this :)
i already did it for TS :)
brilliant! In fact you can extend this to negative numbers by adding in a simple if statement! Still constant time lookup and constant memory! Best if all only logic operaters!
Calm down dude ... He's still a newbie ... ! you should explain more ... !
Hey VeniVidiVici, did you generate this code?? or simply you write it?? because it looks like a lot of implementation, and it is highly probably that red coders hack this solution, even when the test cases are hard to see...
An IGM told me this is not O(1) but O(ab). However I'm a poor newbie and don't know why.
It seems you have chosen a very hard problem. You must try another problem easier than this... You are good enough this problem is so hard don't cry.
anyway, try to solve it before participating in TCO 2015 Final Round because it's a very important classic problem :D
Wow this problem is quite impressive because I have seen in all online judge I have been. I don't know any aproach to attack this kind of problem, good luck Egor
Change your rating back, maybe it's the problem.
Change your rating back, maybe it's the problem.
After a day of thinking, I realized that this was a simple binary search exercise:
Of course to be safe, at the end you can add a check to see if this is the right sum by doing if (ans == a + b) ... Oh wait a minute.
You only forgot to compile it!
Well that is left as an excersise to the reader!
you could solve it with binary index trees in o(log(a+b))
finally accepted with this code. :D
great work the easiest solution I have ever seen :D
Tears of joy in my eyes...The future of Earth is on your shoulders
Можно немного ускорить с помощью meet-in-the-meedle:
I know all of you are alien machine of gods' from 57Ds outspace ,Gods wants all of you to maitain the society of 3Ds,not disturb the 3Ds world,just keep it,not doing crime!!!!!!
Congratulation
for being Specialist from Newbie.No doubt that, you have tried hard for this rating change. Try more. If you rightly do your work, sure, you will be able to solve this hard problem in 8 days. :P
I bet he will become International Grandmaster after 10th of January
Ah yes, in that case he must read my book
Yep... He is working hard. I'm sure he will continue this & he is gonna attend in
Round 285
being International Grandmaster .Great inspiration for new coders !!!
It turned out to be true... How did you know?
Finally I did it:
Wow... You improved... You are specialist now...
try this one :
include <bits/stdc++.h>
typedef long long ll;
define mp make_pair
define pb push_back
using namespace std; vector v; int ans=0; int main() { int a,b; cin>>a>>b; for(int i=0;i<a;i++) v.pb(1); for(int i=0;i<b;i++) v.pb(2); for(int i=0;i<v.size();i++) { if(v[i]==1) ans++; if(v[i]==2) ans++; } cout<<ans; return 0; }
Egor, you must be enjoying this :D Plot twist: he can't solve the problem for real (:ok je sors:).
Now Egor is green! Did you solve this problem?
Hi Egor. I think your code is ok for nonnegative values, but it fails for negative ones!
ur problem looks very similar to this problem.
u should just submit the same solution 5 times, it will give u WA. when u submit 6th time, u will get AC! :)
Думаю это поможет.
.-. LOL very hard problem.
This is a very complex MST problem. It took me two days to reach the conclusion that I can do it like this: Nodes A and B are connected with a total weight of A+B This is my AC code:
Congrats Egor, now you're "Expert" :)) I think you have solved this problem finally, have you? :D
Egor must be truly great rising star of competitive programming since he became blue from grey in such a short period of time! Even lack of contests wasn't an obstacle for him!
One thousand upvotes. Wow.
Now a good number of votes
Solution in 20+ languages https://www.hackerrank.com/challenges/solve-me-first :D
Brainfuck language :)))
if u think that's big, try solving the problem in Whitespace! :)
There's a whole bunch of them.
My personal favourite is ArnoldC :D
it prints the answer for x , y
include <bits/stdc++.h> typedef long long ll; define mp make_pair define pb push_back using namespace std; vector v; int ans=0; int main() { int a,b; cin>>a>>b; for(int i=0;i<a;i++) v.pb(1); for(int i=0;i<b;i++) v.pb(2); for(int i=0;i<v.size();i++) { if(v[i]==1) ans++; if(v[i]==2) ans++; } cout<<ans; return 0; }
It Seems like This post gonna be on Top till next Christmas :D
Use ++i and ++ans.
Congratulation Egor !!!
You are in
div 1
now !!! Wish you best luck.He's improving too soon too fast ... ! :D
I was so confused! His rating is increasing without any contest!!!
this is the magic :P
New year's miracle ... ! \:D/
you are Candidate master now.Now try once again.
International master ... ! way to go Egor ... ! :D
Why you posting a blog for vain Threads.:| you are crazy !
Я хочу поздравить всех пользователей интеллектуальной игры "Clash Of Clans" стем что вы нашли и играете лучшую игру в мире! Поздравляю
.
U BAD U BAD U BAD U BAD U BAD
here is the code: ;)
if you need any more help feel free to contact me ~~~~~
include
using namespace std; int main() { int a,b; cin>>a>>b; cout<<a+b; return 0; } ~~~~~
The editorial is finally here, check it out.
Попробуй закодить в блокноте! Я так закодил и получилось!
[deleted]