| Show all threads Hide all threads Show all messages Hide all messages |
| не могу понять, почему не принимает програму (задача 1243) | Bohdan | | 4 Apr 2017 14:49 | 4 |
#include <iostream> #include <math.h> using namespace std; int main() { char N[51]; cin >> N; int i; for (i = 0; N[i] != '\0'; i++); char Y[4]; int counter = 0, a = 0; if (i % 3 == 0) { for (int j = 0; j < i; j += 3) { Y[0] = N[j]; Y[1] = N[j + 1]; Y[2] = N[j + 2]; Y[3] = 0; if (counter % 2 == 0) { int temp = atoi(Y); a += temp; } if (counter % 2 == 1) { int temp = atoi(Y); a -= temp; } counter++; } } if (i % 3 != 0) { int start = i % 3; for (int maloe = 0; maloe < start; maloe++) { Y[maloe] = N[maloe]; } Y[start] = '\0'; int temporary = atoi(Y); a -= temporary; int counter = 0; for (int j = start; j < i; j += 3) { Y[0] = N[j]; Y[1] = N[j + 1]; Y[2] = N[j + 2]; Y[3] = 0; if (counter % 2 == 0) { int temp = atoi(Y); a += temp; } if (counter % 2 == 1) { int temp = atoi(Y); a -= temp; } counter++; } } cout << abs(a%7); system("pause"); return 0; } Я делаю ввод в строку, тогда считываю по 3 элемента и делаю их один числом (например, 123456 в числа 123 и 456), тогда по признаку деления на 7 узнаю остаток. Если число, например 12435 то я делю его на 12 и 435 и по работаю по тому же принципу. На моих проверках всё работает хорошо, а система выдаёт WA на 3 тесте. Could you please open task-related themes in task discussions rather than common? Could you please publish link to mathematical background of your solution? Btw, Test your solution on numbers 222223 and 223222. Could you please read task discussions and find simple division digit-by-digit in the every second topic? Edited by author 26.03.2017 23:20 Сударь, вы очень-очень мудрёно решаете. Код этой задачи - в несколько строк. |
| seems there is illegal tests | Shen Yang | 2016. Magic and Science | 4 Apr 2017 14:14 | 2 |
1 1 366 -565864 609690 15155 516588 775970 765044 814205 -251004 532061 magion will stop in the middle of second args...please check it sorry ,it's my mistake,answer should be 8587308.19597172360000000000 |
| Решение C++ | Solution C++ | Viktor | 1068. Sum | 4 Apr 2017 11:39 | 2 |
#include <iostream> using namespace std; int main(){ int n, i = 0; cin >> n; while (n != 1){ if (n <= 1){ i+= n; n++; } else if (n >= 1){ i+= n; n--; } } cout << i+1; return 0; } |
| Решение C | Solution C | Viktor | 1068. Sum | 4 Apr 2017 04:37 | 1 |
#include <stdio.h> int main() { int n, i = 0; scanf("%d", &n); while (n != 1){ if (n <= 1){ i+= n; n++; } else if (n >= 1){ i+= n; n--; } } printf("%d", i+1); return 0; } |
| I think it is not geometry problem ->>>>>PHYSICS problem | IlushaMax | 1192. Ball in a Dream | 3 Apr 2017 23:19 | 1 |
|
| LOL O(N*M) works...without any data structures | IlushaMax | 1126. Magnetic Storms | 3 Apr 2017 22:51 | 1 |
|
| WA #6 | pidgey | 1126. Magnetic Storms | 2 Apr 2017 17:42 | 1 |
WA #6 pidgey 2 Apr 2017 17:42 Can someone please tell how the test looks like? |
| Wooohooooooooo AC ->some hints | IlushaMax | 2033. Devices | 31 Mar 2017 17:23 | 1 |
Don't forget about saving MIN PRICE of device Edited by author 31.03.2017 17:39 |
| Something strange... | Vukasin | 1023. Buttons | 31 Mar 2017 14:16 | 3 |
When i write my program like: #include<cstdio> long long int i,k; int main(){ scanf("%lld",&k); i=k / 3; while(k % i!=0){ i=k /(k / i +1); } i got AC,but when i change it to: #include<cstdio> int main(){ long long int i,k; scanf("%lld",&k); i=k / 3; while(k % i!=0){ i=k /(k / i +1); } printf("%lld",(k / i-1)); } printf("%lld",(k / i-1)); } i got WA5...does anyoe know how is that possible? wtf i=k / 3; ?? If k%(l+1)==0 then 2nd have a chance to win. And 1st wins if k%(l+1)!=0 try it: for (l=3;k%l!=0;l++);; Edited by author 31.03.2017 14:34 |
| WA #13? | Ionkin M [Samara SAU #617] | 1023. Buttons | 31 Mar 2017 13:30 | 1 |
WA #13? Ionkin M [Samara SAU #617] 31 Mar 2017 13:30 Check your program for very big K. It helped me. Edited by author 31.03.2017 14:38 |
| I guessed - can someone explain why? | Steve | 1161. Stripies | 30 Mar 2017 21:34 | 4 |
I got AC on this simply by guessing that combining the stripies from the largest down to the smallest would result in the smallest colony size. Can someone explain what mathematical or logical reasoning would be used to arrive at this conclusion, or prove that this conclusion would be true? I guessed the same and also I want to know mathematical proof The factor 2 does not matter -- you will always find one 2 which was sqrt'ed (n-1) times, ..., one 2 not sqrt'ed. OOH, there will be exactly two given number which got sqrt'ed (n-1) times, ..., one given number that got sqrt'ed once. Therefore, you will want larger numbers be sqrt'ed more times. Edited by author 22.03.2016 12:08 I can explain Okay, we have sequence m1,m2,m3,m4.... of weights in input But now imagine that we have a heap of stripies with their weights. Our answer (for example n=4) will be: 2*sqrt(m1*2*sqrt(m2*2*sqrt(m3*m4))) for greater understanding write it on a sheet. So we need to maximize it but we don't know order of m1,m2,m3,... which give max answer. It's clear that if 2*sqrt(m1*2*sqrt(m2*2*sqrt(m3*m4))) should be maximum then m1*2*sqrt(m2*2*sqrt(m3*m4)) (in sqrt) should be maximum too. Reasoning in this way we understand that we need m3*m4 be maximum. So this sequence should be sorted in this way: m4>=m3>=m2>=m1 I hope my English is enough to explain it)))) Edited by author 31.03.2017 19:50 |
| If you use P(P+2A-1)=2N but have WA | IlushaMax | 1120. Sum of Sequential Numbers | 30 Mar 2017 20:40 | 2 |
Don't forget that not only P should be divider of 2N but P+2A-1 should be divider of 2N too. It was my mistake when I got WA 7 Thanks! Nikita UCSD Pascal 30 Mar 2017 20:40 |
| Please give me test 3. I am get WA | Alex | 1796. Amusement Park | 30 Mar 2017 19:36 | 1 |
|
| Why '''''' like '_''' = True? | Vokin Andrei (vokin_andrei@mail.ru) | 1177. Like Comparisons | 29 Mar 2017 23:38 | 4 |
Reason Han Wentao 19 Feb 2002 08:36 In fact, the string are two apostrophe symbols, and the template are an underline and an apostrophe symbol. An underline can match any single character, and the other apostrophe can match the second apostrophe. So, the answer is 'YES'. Re: Reason Ionkin M [Samara SAU #617] 29 Mar 2017 23:38 |
| С++ TLE(test 12) | Bohdan | 1100. Final Standings | 28 Mar 2017 04:07 | 2 |
#include <iostream> using namespace std; int main() { long N; cin >> N; long **array = new long*[N]; for (long i = 0; i < N; i++) { array[i] = new long[2]; long temp, temp2; cin >> temp >> temp2; array[i][0] = temp; array[i][1] = temp2; } cout << endl << endl;
long l, r, i, k, buf; k = l = 0; r = N - 2; while (l <= r) { for (i = l; i <= r; i++) if (array[i][1] < array[i + 1][1]) { swap(array[i], array[i + 1]); k = i; } r = k - 1; for (i = r; i >= l; i--) if (array[i][1] < array[i + 1][1]) { swap(array[i], array[i + 1]); k = i; } l = k + 1; } for (long i = 0; i < N; i++) { cout << array[i][0] << " " << array[i][1] << endl; } return 0; } What is wrong with it?( I use bubbleshaker sort. You shouldn't use bubble sort. You the only should receive the same sort result. |
| wrong tests! n >= 3! | -XraY- | 1103. Pencils and Circles | 28 Mar 2017 00:04 | 3 |
my program with while(n < 3) printf("there are some stupid tests!\n"); gets Output limit exceeded 3. Please, check your tests! There is some trash in the end of a file in test 3. So, my multitest found it) can you elaborate on this? czu i'm getting WA on test4. would it have to do with this? |
| MLE #21 | Maxm | 1510. Order | 27 Mar 2017 21:33 | 6 |
I don't understand. I use quicksort and then find solution very fast. MLE #21 say me that memory limit! I use c#. Edited by author 26.03.2017 21:16 Edited by author 26.03.2017 21:16 Edited by author 26.03.2017 21:17 Edited by author 26.03.2017 21:37 MLE - your program spent too much memory. No perfomance problem detected. Looks like you read all N inputs into list. Try using dictionary K -> count. I use Dictionary and get MLE too. I think problem in input data. I enter input data like: string[] input = Console.In.ReadToEnd().Split( new char[] { ' ', '\t', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); And add in dictionary for (int i = 0; i < input.Length; i++){ ... } I don't understand what's wrong :( Was wrong. Dictionary => TLE. Got input into List, sorted List, took middle one => AC. Just avoid reading whole input. Use something like static int readInt() { return Int.Parse(Console.ReadLine()); } Thanks! I read data like: static int readInt() { return Int.Parse(Console.ReadLine()); } But ... I have WA #25.. |
| what's wrong??? | [SESC USU]Rudnev Vladimir | 1100. Final Standings | 26 Mar 2017 12:39 | 7 |
I think, i do all rigth, but i've WA1=(( I don't understand output type, that's mean what me should to print. Sorry for my English... var a,b:array[1..15000]of longint; asd,asd1,n,i,j:longint; begin read(n); for i:=1 to n do read(a[i],b[i]); for i:=1 to n-1 do for j:=i+1 to n do if b[i]<b[j] then begin asd:=b[i]; b[i]:=b[j]; b[j]:=asd; asd1:=a[i]; a[i]:=a[j]; a[j]:=asd1; end; for i:=1 to n do begin write(a[i],' ',b[i]);writeln;end; end. Ou fuck, i've do sort dont rigth.... Ou fuck, i've do sort dont rigth.... I think your solution will be TL. Use merge, or another fast sort I think that you answered two years later than it was necessary :) |
| Can't get what's wrong with my BFS solution | ComebackSeason | 1106. Two Teams | 26 Mar 2017 00:55 | 1 |
//problem solved (issue of different compilers of my local PC and judge one) Edited by author 26.03.2017 16:41 |
| Fine | bdzxt | 1148. Building Towers | 24 Mar 2017 18:48 | 2 |
Fine bdzxt 12 Mar 2017 08:23 //tower.in 1000 60 10 1 2 3 4 5 20170312 666666666 888888888 999999999 427749136024120470 427749136024120471 427749136024120472 -1 //tower.out 427749136024120472 10 9 8 7 6 5 4 3 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 10 9 8 7 6 5 4 3 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 3 10 9 8 7 6 5 4 3 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 3 2 1 10 9 8 7 6 5 4 3 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 3 2 3 10 9 8 7 6 5 4 3 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 3 4 3 10 9 8 7 6 5 4 3 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 3 2 3 4 5 6 7 6 7 6 7 8 9 8 7 6 5 6 7 8 9 10 9 8 9 10 11 10 9 8 7 6 5 4 3 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 3 2 1 2 3 2 3 4 3 4 3 4 5 6 7 8 9 8 9 10 11 12 11 10 9 10 9 10 9 10 9 8 9 10 9 8 7 6 5 4 3 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 3 2 3 2 3 4 5 6 5 4 5 6 5 4 3 4 5 6 7 8 9 10 9 8 9 8 7 6 7 6 5 4 5 10 9 8 7 6 5 4 3 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 3 2 3 4 3 4 5 4 5 6 7 8 9 10 9 8 7 8 9 8 9 10 9 8 9 10 11 12 11 12 13 14 13 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 7 6 5 4 3 2 1 2 3 2 1 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 7 6 5 4 3 2 3 2 1 2 1 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 8 7 6 5 4 3 2 1 2 1 2 1 I finished it in 0.015s. |