| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| pritf; scanf; c++ (visual studio) | nightmare1296 | | 30 мар 2016 12:43 | 2 |
Please, help me understand, how turn on printf and scanf in my program. If I write : int Solution (int n, int a, int b) { return (2*n*a*b); } int main() { int n,a,b; scanf ("%d %d %d", &n, &a, &b); printf ("%d", Solution (n,a,b)); return 0; } system will throw "Compilation error" with vtje2d-4h6iqg.cpp(9) : error C3861: 'scanf': identifier not found vtje2d-4h6iqg.cpp(10) : error C3861: 'printf': identifier not found. If i write the same, with #include "stdafx.h" on the top, system will throw "Compilation error" with rvkkio-7db2pu.cpp(4) : fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory #include <cstdio> Edited by author 30.03.2016 12:44 |
| Got Accepted | Megapolice | 1785. Трудности локализации | 29 мар 2016 18:49 | 4 |
var n: integer; begin readln(n); if (n>=1) and (n<=4) then writeln('few'); if (n>=5) and (n<=9) then writeln('several'); if (n>=10) and (n<=19) then writeln('pack'); if (n>=20) and (n<=49) then writeln('lots'); if (n>=50) and (n<=99) then writeln('horde'); if (n>=100) and (n<=249) then writeln('throng'); if (n>=250) and (n<=499) then writeln('swarm'); if (n>=500) and (n<=999) then writeln('zounds'); if n>=1000 then writeln('legion'); end. will be better with CASE OF IMHO, using CASE OF operator, You'll get more esthetic look, no more. And insignificant advantage in performance. IlushaMax, could you check message year and don't answer if message is 2 (or more) years old? Thanks in advance. |
| Please help! Wrong answer (C++) | Yurii Leskiv | 1001. Обратный корень | 29 мар 2016 12:43 | 6 |
My program works fine in console, but for some reason I get wrong answer on test 9. Could someone point out where is the problem in my code? #include <iostream> #include <vector> #include <math.h> #include <iomanip> using namespace std; int main() { double num; vector<long long> input; int limit = 256 * 1024 / sizeof(long long); for (int k = 0; (cin >> num) && k <= limit; k++) { if (num != (long long)num || num < 0 || num > pow(10.0, 18)) return 0; input.push_back((long long)num); } for (int i = input.size() - 1; i >= 0; i--) cout << fixed << setprecision(4) << sqrt(input[i]) << endl; return 0; } Edited by author 28.03.2016 23:17 Edited by author 28.03.2016 23:18 Edited by author 28.03.2016 23:18 Limit is wrong. Min number size is 2 bytes - "1 ". In common, you shouldn't check if input is correct. It's supposed to be always correct. Reading like: while (cin >> number) { input.push_back(number); } should be enough. If you want to check input (for lulz?) you should fail your program in more visible way - via return not 0, throw something etc. Judge system will return another error, not WA. Edited by author 28.03.2016 23:43 Another note. You read number into double, convert it into long long, convert it back to double and finally call sqrt. Why do you need 2 conversions in the middle? Shouldn't you better use vector<double> input? Sorry for stupid question: what is WA? |
| Thanks to authors! | __Andrewy__ | 2063. Чёрные и белые | 28 мар 2016 17:02 | 8 |
Никак не пойму,что обозначает "Во всех тестах, кроме первого, расстановки зашифрованы. Вы не должны пытаться расшифровывать эти данные (и не обязаны их считывать), однако наличие во вводе этой информации позволяет нам гарантировать, что в этой задаче заранее определённые тесты, которые не подстраиваются под вашу стратегию." Как выглядят эти данные и влияют ли они на решение? И вопрос тем,кто решил-всегда ли мы можем "угадать в среднем",что у нас в очередной игре ровно один 0(или 1)? P.S. Пока дошёл только до 70 теста P.S. Уже решил.Не заметил одну особенность. Edited by author 25.10.2015 00:00 The solution is independent to this data. It's hard to provide test data to checker programm and not to provide it to participant. Can you tell what feature you found? I still have WA 70 too and need any idea to improve my program. I have one question. If there are three balls: 1st - black, 2nd - white and 3rd - unknown color, is it possible to find numbers of 2 balls of the same color or no? Obviously it's not possible if you talk of a 100% chance. Then how can we guess it with 80% chance? I thought that we always can determine these positions with 100%. Correct me if I am wrong. «I thought that we always can determine these positions with 100%. Correct me if I am wrong.» Yes, you are wrong. Hint: try to think of a certain specific test that will aim to fail your algo. More particularly, even your test above will do — black, white, unknown. We have options of <1 2> (obviously wrong), <1 3> (wrong if 3 is white) and <2 3> (wrong if 3 is black). So we can't guess with a 100% chance. Anyways, here's that very minor hint i can give: use random(). Edited by author 28.03.2016 17:12 Thanks, I just wanted to know in what direction to think further... Edited by author 28.03.2016 17:44 Edited by author 28.03.2016 17:44 |
| Any ideas what test #17 is? | ToadMonster | 1306. Медиана последовательности | 28 мар 2016 15:24 | 3 |
Lost ac. WA 17 Looks like it isn't "n<=0", it isn't about integer overflow during even-length sequence overflow calculation. Edit: oh alright, congratulations. Edited by author 28.03.2016 16:15 Thanks, finally got AC. Was childish error in checking if N is odd or even. |
| Pythion IDE | whatsmyname | | 28 мар 2016 03:07 | 1 |
Hi , What IDE or Editor or Online Interpreter do you guys use for Python? Please help! Thanks in advance |
| Constraints | Alex Danilyuk [Dandelion] | 1834. Теннисная ракетка | 28 мар 2016 01:32 | 1 |
Constraints Alex Danilyuk [Dandelion] 28 мар 2016 01:32 Why constraints are so small? |
| I solved, but I want know how solve at 0.015 sec? | __Andrewy__ | 2032. Теория заговора и ребрендинг | 27 мар 2016 21:21 | 1 |
My algo is O(max(a,b,c)). |
| May I regard "fire" as making the straw height INF? | Ade | 2075. Берегите брови! | 27 мар 2016 15:00 | 3 |
I always WA#2 Edited by author 27.02.2016 15:28 Edited by author 27.02.2016 15:30 Yes you can, in practice it will be max value of type used for storing straw height. |
| What's test 2? Can anyone help me? | TFYS | 2075. Берегите брови! | 27 мар 2016 15:00 | 1 |
|
| alphabet | Wroclaw Smurfs | 2059. Не общие подпалиндромы | 27 мар 2016 13:26 | 2 |
alphabet Wroclaw Smurfs 11 июл 2015 14:01 Do strings consist of only lower-case letters of latin alphabet ? |
| Problem 1306 "Sequence Median" has been rejudged (+) | Sandro (USU) | 1306. Медиана последовательности | 27 мар 2016 12:27 | 1 |
New tests were added. About 160 solutions got WA verdict on them. |
| WA #1 | João Pedro Franco | 1837. Число Исенбаева | 27 мар 2016 05:57 | 1 |
WA #1 João Pedro Franco 27 мар 2016 05:57 Why? My solution is ok when i run with other tests that i have seen in this forum, but when i submit here, i get WA#1! Is there a problem about the output? Thanks. |
| Тест №8. Какой должен быть ответ? | Ananstasya | 1083. Факториалы!!! | 27 мар 2016 02:17 | 2 |
Тест №8. Какой должен быть ответ? Ни у кого нет тестов (кроме тех, кто создавал задачи и соответственно тесты). Мы можем только догадываться какой может быть тест № а , если смотреть на каком тесте валится наш код. В общем методом подбора |
| Why Compilation error? | vladi | 1025. Демократия в опасности | 27 мар 2016 00:53 | 2 |
var t: real; n, k, i,j: integer; a:array [1..101] of integer; begin readln(n); for i := 1 to n do begin read(a[i]); end; for i:=1 to n do begin for j:=1 to n do begin if a[i]<a[j] then begin swap(a[i],a[j]); end; end; end;
for i:=1 to (n div 2)+1 do begin t:=t+((a[i] div 2)+1); end;
write(t); end. Pascal hasn't function swap. You should to write it yourself |
| AC | vtalgo16_vgubarev | 1438. Time Limit Exceeded | 26 мар 2016 17:18 | 3 |
AC vtalgo16_vgubarev 9 мар 2016 23:39 What was pretty interesting problem. Ty Edited by author 26.03.2016 17:18 If you have problems with test 10, ensure that you determine command type correctly. For instance: ifi = 10 printer = 20 gotoend = ifi + printer print gotoend Re: AC vtalgo16_vgubarev 26 мар 2016 17:18 Tokenization with finite state machine Edited by author 26.03.2016 17:19 |
| Getting WA#2. Anybody got the test case? | szawinis | 1353. Миллиардная Функция Васи | 26 мар 2016 14:35 | 2 |
Hint: consider what allowed for first digit |
| Where is the error ?? 9 test fails . Pascal . Где ошибка?? 9 тест не проходит. Паскаль. | Andriy | 1636. Штрафное время | 26 мар 2016 02:41 | 3 |
var t1,t2,i,k,q:integer; a:array [1..10000000] of integer; begin read(t1,t2); for i:=1 to 10 do read(a[i]); for i:=1 to 10 do begin if a[i]>0 then k:=k+a[i]; end; if t1<t2 then begin q:=(k*20)+t1; if q<=t2 then write('No chance.') else if q>t2 then write('Dirty debug :('); end else if t1>=t2 then begin write('No chance.'); end; end. Edited by author 01.11.2014 13:12 Edited by author 01.11.2014 13:12 Why SUCH BIG MASSIVE if 10 elements will be used What is "k" initial value? |
| Where a mistake? | Eugene | 1472. Марсианская армия | 25 мар 2016 21:04 | 1 |
In example we have: 7 soldiers 1 - commander 2 - Ki = 1, Ci = 10 3 - Ki = 2, Ci = 5 4 - Ki = 2, Ci = 3 5 - Ki = 3, Ci = 1 6 - Ki = 4, Ci = 2 7 - Ki = 5, Ci = 3 It's right? Now, by a problem A1 === 1, A5 = A6 = A7 === 0. A2, A3 and A4 - may be either 0 or 1, yes? if A2 = 1 and A3 = 0 and A4 = 1 then profit = C7 * |A7 - A3| + C6 * |A6 - A3| + C5 * |A5 - A3| + C4 * |A4 - A2| + C3 * |A3 - A2| + C2 * |A2 - 1| = 3 * 0 + 2 * 0 + 1 * 0 + 3 * 0 + 5 * 1 + 10 * 0 = 5 Then answer min profit = 5. But in example is 8.00 I understood! 4 - it's soldier too and his A4 === 0 too Edited by author 25.03.2016 21:20 |
| Hahaha | IlushaMax | 1636. Штрафное время | 25 мар 2016 21:02 | 1 |
Hahaha IlushaMax 25 мар 2016 21:02 |