| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| This is running well on Java | Farruh-WIUT | 1877. Велосипедные коды | 21 июн 2017 04:44 | 2 |
import java.util.Scanner; /** * Created by macbookpro on 2/19/15. */ public class JavaThieves877 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int c1 = Integer.parseInt(scanner.nextLine()); int c2 = Integer.parseInt(scanner.nextLine()); if(c1 % 2==0 || c2 % 2!=0 ) { System.out.print("Yes"); } else if(c1 % 2 != 0 || c2% 2== 0) { System.out.print("No"); } } } Nevermind I didn't read that this is running well:) Edited by author 21.06.2017 04:49 |
| wa 13 | LastOne | 1716. Альтернативное решение | 20 июн 2017 22:59 | 2 |
wa 13 LastOne 13 июн 2017 00:51 You can try use these tests: 4999 12832 ->2455.1680336 5000 12345 ->2490.9210000 4987 9999 ->50.7443353 1234 3456 ->394.1183144 2976 6547 ->952.8800403 3487 8000 ->1448.9340407 4955 11111 ->1820.5574168 456 968 ->99.1228070 43 123 ->10.4651163 1 2 ->1 4 9 ->2.2500000 3 9 ->0 2 5 ->1.5 2 4 ->1 4399 13013 ->352.6492385 4321 9923 ->1803.1751909 4001 10500 ->1877.1534616 4000 10001 ->2000.4992500 4000 10000 ->2000.5000000 4123 9999 ->2015.9083192 |
| "Ordinary" minus '-' from ASCII set is OK. | Nikita Mogilevets | 1149. Танцы синуса | 20 июн 2017 22:50 | 1 |
At first I thought I was getting WA's because of the wrong minus sign. Actual reason was printing integers. I was trying to print integers using just PUTCHAR. Of course it worked fine for 0-9. And was failing for other numbers. |
| I solved it with Python | Nikita Mogilevets | 2002. Тестовое задание | 20 июн 2017 00:56 | 1 |
I tried to solve it with C++. It was long. It was PAINFUL! Finally, I didn't managed to solve it in C++. And then I just opened my Python IDE and solves it within 10 minutes. Just AC first attempt. The task is evil. |
| Use heap. Use number 0.5*K+1. | Nikita Mogilevets | 1025. Демократия в опасности | 17 июн 2017 01:05 | 1 |
|
| Right Algo: | bsu.mmf.team | 1222. Chernobyl’ Eagles | 16 июн 2017 22:11 | 5 |
The product of natural numbers with a given condition in this problem will be maximal if and only if the middle arithmetic of these numbers is the most closely to the number e=2.71828... It's a mathematical sentence which are proved! P.S. Sorry for my bad English Why is that true? You can get AC without math :P Well, you only need to understand that optimal partition can't contain any x >= 4(as 2*(x-2) >= x in this case), it obviously can't contain ones, and it can't contain more than 2 copies of 2, as 2*2*2<3*3. Surpisingly, there is only one way to express any x >= 2 as sum of 3's and not more than two 2's. That's a very nice idea. Let me clarify it for those who had problems understanding bsu.mmf.team's English. First of all, 'middle arithmetic' is an arithmetic mean. The thing is, the product will be maximal if (a_1 + a_2 + ... + a_n) / n ≈ e. Well, it's not hard to figure out that the output of the program should be something like that: 3 * 3 * 3 * ... * ? |
| AC in 0.249 and 8668 KB (RMQ for lca) | sak3t | 1471. Расстояние в дереве | 15 июн 2017 22:06 | 2 |
used RMQ using segment tree to find lca in log(n) total time complexity O(n+q*(lgn)) = O(q*lgn) Almost the same numbers (0.268, 11500) for table for 2^i -th ancestor. |
| Graph problems ratings are really strange. | Nikita Mogilevets | 1291. Шестерёнки | 14 июн 2017 16:52 | 1 |
Some graph problems having very low rating (caravans, Ivan's car) are quite hard to solve while some other problems (like Gear-wheels, Labyrinth) have rating two times higher and are incredibly easy. |
| My solution works as follows : | Nikita Mogilevets | 1139. Городские кварталы | 13 июн 2017 21:25 | 1 |
For each x (x=0,1,2,..,n-1) (x is horizontal axis) find y0=x*tg(a) and y1=(x+1)*tg(a), where tg(a) is (m-1)/(n-1). Add to answer floor (y1) - floor(y0) +1. If y1 is a whole number then subtract 1 from answer. |
| what mistake? | Evgenii | 1991. Битва у болота | 13 июн 2017 18:03 | 2 |
program pr; Var n,k,i,s,q:integer; a:array[1..100000] of integer; b:array[1..100000] of integer; Begin q:=0; read(n,k); for i:=1 to n do readln(a[i]); for i:=1 to n do b[i]:=k-a[i]; for i:=1 to n do begin if b[i]<0 then s:=abs(b[i]); if b[i]>=0 then q:=q+b[i] ; end; write(s,' ',q) End. |
| WA#5 pls | Roflan Pominki | 1585. Пингвины | 13 июн 2017 10:24 | 1 |
WA#5 pls Roflan Pominki 13 июн 2017 10:24 What is the WA#5?Какой WA#5? |
| Лишние переменные в условии | InDevRus | 1992. CVS | 13 июн 2017 01:10 | 2 |
Можете объяснить, зачем даётся переменная m. Я успешно решил задачу без её использования: public static void Main() { var queryCount = int.Parse(Console.ReadLine().Split(' ')[0]); var queries = Enumerable .Range(0, queryCount) .Select(number => Console.ReadLine()) .ToArray(); foreach (var line in Solve(queries)) Console.WriteLine(line); } Не все люди решают задачи как Вы. Некоторым людям нужно количество запросов, чтобы, например, понять какого размера брать массив или тому подобное. Часто можно не учитывать какие то параметры, но это не значит, что они не нужны. |
| Как уменьшить расход памяти? | elizoorg | 1306. Медиана последовательности | 12 июн 2017 17:55 | 2 |
Вот код... Я не понимаю как уменьшить расход памяти... но программа написана верно и работает... #include<iostream> using namespace std; int main(){ int n,i,j; float x; cin >> n; unsigned int a[250000]; for(i=1;i<=n;i++){ cin>>a[i]; } bool k=true; for (i=1;(i<n && k==true);i++){ k=false; for(j=1;j<=n-i;j++){ if (a[j]>a[j+1]) { swap(a[j],a[j+1]); k=true; } } } if (n%2==0){ cout << (a[n/2]+a[n/2+1])/2; } else {cout << a[n/2];} } Не храни 250 000 unsigned int 'ов. Храни, например, только половину -- 125 000. Тогда, очевидно, расход памяти сократится в два раза. Edited by author 12.06.2017 17:55 |
| Binary indexed tree(Fenwick tree) | Gilles Deleuze | 1126. Магнитные бури | 11 июн 2017 18:06 | 1 |
I solved this problem using a Binary indexed tree modification(read about Counter tree fenwick). It utilizes 2n memory and lets you find MAX of a subarray in logarithmic time. My solution: 0.062s, 812 kb, yet i haven't tried to do some optimization, I used std::vector which is slower than an array. Nevertheless, I'm pretty ok with such a result |
| Should this problem be solved with DP? | Gilles Deleuze | 2110. Удалить или максимизировать | 11 июн 2017 04:35 | 2 |
Could someone provide any hint? Edited by author 10.06.2017 23:14 Here's a brainless but simple way i did it. 0. Mini-optimization: remove all repeated numbers, leaving only unique ones, and reduce k respectively. Let A be the array with those unique numbers. 1. Make a list of indices that point to numbers which have 1st bit 1, 2nd bit 1, ..., 32nd bit 1. Like for example: L[1..32][0..nmax], L[5][0] — amount of numbers which have 1 on 5th bit, A[L[5][1]], A[L[5][2]], ... — those numbers. 2. Main algo. Make current_result = 0. Going from higher bit to lower (i = 1..32), if list is not empty (L[i][0] > 0) and ith bit is 0 in current_result, then choose random index j, and do current_result = current_result or L[i][j]. Increase i and repeat either till you reach the last bit or reach the limit of numbers to be deleted. Then update the best reached result. 3. Spam step 2 for a certain time. I initially decided to consume entire 2s, but apparently even 200ms is enough to ac. Clever way is DP, yeah, but requires thinking :) |
| HELP!!! Paskal | SanaKomissarova | 1607. Такси | 10 июн 2017 17:58 | 8 |
var a,b,c,d:integer; begin Read(a,b,c,d); While a<>c do begin a:=a+b; c:=c-d end; a:=c; WriteLn(a); end. Почемууу(( Why((( Карочь хрень полная Поможете?? Help me? Edited by author 25.03.2016 14:04 Have you tried to run your program on task sample locally, using debugger? Or at least print A and C values at the end of each cycle iteration? Why no? You should try. Edited by author 25.03.2016 15:29 Refer the example. I'm just a novice programmer. I try very hard. Help. I don't understand. ( YANDEX translator) "Refer the example" И чо? "Я отладила программу на примере, пытаюсь сдать acm, получаю WA. Почему?"? "При локальном запуске, на примере, получаю неправильный ответ/программа зависает. Почему?"? "Что такое debugger?"? В общем, телепаты в отпуске. P.S. Посмотрел попытки на acm.timus.ru. Все TLE 1. Патамушта цЫкл While a<>c do begin a:=a+b; c:=c-d end; бесконечный, как и ожидается. Edited by author 26.03.2016 03:04 Ну да :D Бывает. А ты на янде переводил? Особенно это выдал яндекс Патамушта цЫкл Они никогда не будут равны, если не состыкуются. Возьмем данные 150 50 1000 100 200(+50) 900 (-100) 250 800 300 700 350 600 400 500 450 400!!!! Edited by author 10.06.2017 17:58 |
| What's in test #4? Please, help | Sapunovnik | 1319. Отель | 10 июн 2017 15:16 | 1 |
Hi. My solution works on my computer but there is not. What's wrong with my code? #include <iostream> using namespace std; int main() { int n, c = 1; int pix[100][100]; for ( int i = 0; i < n; ++i ) { for ( int j = 0; j < n; ++j ) { pix[i][j] = 0; } } cin >> n; for ( int i = 0; i < n; ++i ) { for ( int j = (n - 1); j >= 0; --j ) { if ( pix[i][j] > 0 ) continue; int ii = i, jj = j; while ( ii < n && jj < n ) { pix[ii][jj] = c; ii++; jj++; c++; } } } for ( int i = 0; i < n; ++i ) { for ( int j = 0; j < n; ++j ) { cout << pix[i][j] << " "; } cout << endl; } return 0; } Edited by author 10.06.2017 15:16 Edited by author 10.06.2017 15:16 Edited by author 10.06.2017 15:17 |
| Wrong answer test 4 in Java 1.7 please help me | Axmadjon | 1206. Сумма цифр суммы чисел | 9 июн 2017 14:32 | 2 |
import java.util.Scanner; public class _1206 { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = 36; long k = s.nextInt(); while (k > 1) { n *= 55; k--; } System.out.println(n); } } Edited by author 05.05.2014 17:02 |
| AC (Pascal) | ArcKontyR | 1001. Обратный корень | 9 июн 2017 11:40 | 1 |
var a:array [1..200000] of int64; n,i: integer; begin while not seekeof do begin inc(i); read(a[i]); end; for n:=i downto 1 do begin writeln(sqrt(a[n]):4:4); end; end. I copied the solution from the other guy p.s. Sorry man, i dont know your nickname Edited by author 09.06.2017 11:43 |
| AC (Pascal) | ArcKontyR | 1880. Собственные числа Psych Up | 9 июн 2017 11:20 | 1 |
var i,j,n,n#,n2,a,m:integer; l:array[#..400#,#..2] of longint; begin read(n); for i:=# to n do read(l[i,#]); read(n1); for i:=# to n# do begin read(a); for j:=# to 400# do if l[j,#]=a then l[j,2]+=#; end; read(n2); for i:=# to n2 do begin read(a); for j:=# to 400# do if l[j,#]=a then l[j,2]+=#; end; for i:=# to 400# do if l[i,2]=2 then m:=m+#; writeln(m); end. Where is # change it with 1 |