Common Board| Show all threads Hide all threads Show all messages Hide all messages | | Why if n=4, the answer is 204 | plague | 1586. Threeprime Numbers | 9 Feb 2015 19:41 | 3 | Explain me please, why if n=4, the answer is 204. I get 2513. 1031 is not a THREE-PRIME nummber. 103 is THREE-PRIME nummber, but 031 isn't, it's TWO-PRIME number Thank you for question and answers. It help to understand the task. | | WA#5 CLOSED | dingo | 1306. Sequence Median | 9 Feb 2015 19:17 | 2 | Here is my code: ----- [The code was here] ----- I've got the point. Thank you. Edited by author 17.07.2011 18:48 | | RE - #14..(c++). because of map<string,int>? | OIdiot | 1837. Isenbaev's Number | 9 Feb 2015 07:13 | 2 | /* Machine: Class4_B2 System: Windows7 SP1 32bit */ [code deleted] Edited by moderator 19.11.2019 23:15 My bad.. I thought it only contains 100 names, but 300 in fact. | | different between undefined and 3 | amirshir | 1837. Isenbaev's Number | 9 Feb 2015 06:59 | 2 | what's different between undefined and 3? can you help me? Isenbaev -> a -> b -> c. In this chain, a is 1, b is 2 and c is 3. Obviously,there is a path from Isenbaev to c. But In this situation: Isenbaev -> a -> b. c. c isn't a teammate of anyone who is connected with Isenbaev. So, c is 'undefined'. | | WA#2 | LNCP | 1132. Square Root | 8 Feb 2015 09:54 | 2 | WA#2 LNCP 8 Feb 2015 09:50 I use Tonelli-Shanks algo,but i got WA#2.By now I had read all te topic but hadn't found the error.Please give me some hints or cases. the key code: int inverse(int a, int m)//thr inverse element of a(modulo m); int quickpower(int a, int n, int m)//a^n(modulo m); void sqrt(int a, int p) { if(p==2) { cout << 1 << endl; return; } if(quickpower(a,(p-1)/2,p)!=1) { cout << "No root" << endl; return; } int s, t = 0, b = 0, i, j, x, y, inv, N; for (s = p - 1; !(s & 1); s /= 2) t++; inv = inverse(a, p); x = quickpower(a, (s + 1) / 2, p); for (N = 2; quickpower(N, (p - 1) / 2, p) == 1; N++); for (i = t - 2; i >= 0; i--) { b = b ? b*b%p : quickpower(N, s, p); y = x*x%p*inv%p; for (j = 1; j <= i; j++) y = y*y%p; if (y != 1) (x *= b) /= p; } if (2 * x < p) cout << x << " " << p - x << endl; else cout << p - x << " " << x << endl; return; } I had got AC now.Really a small mistake! | | Runtime Error 1003 Parity | Sunny | 1003. Parity | 8 Feb 2015 09:10 | 1 | Deleting this post... had to hack another solution. Still don't see what was wrong with the original approach... must have been some kind of parsing issue with the input. Edited by author 08.02.2015 09:36 | | test 16 is terribly! HELP!!!!!! | Vasya | 1286. Starship Travel | 7 Feb 2015 20:48 | 5 | I am sure that my program is right, but i get WA on test 16. Do somebody know this test or can say something interesting? I think, you haven't really proved your algorithm. I guess it's much more interesting than just gcd. Sergei Try using long long and read your data like this scanf( "%I64d%I64d%I64d%I64d%I64d%I64d", &p, &q, &sx, &sy, &ex, &ey ); Thanks for all, if not you I die near my PC. | | Loop in python | crc | 1013. K-based Numbers. Version 3 | 7 Feb 2015 18:55 | 2 | a "for"-loop in python for integers 1 <= i <= 10^18 needs a lot of time. Is there a way to avoid to do such a huge for-loop? Edited by author 21.01.2015 20:28 You should calculate recurrence with Matrix and use quick-power to calculate the power of Matrix.Do you need details about the algo? | | wa 5 | ziwert | 1607. Taxi | 7 Feb 2015 17:20 | 4 | wa 5 ziwert 21 Sep 2010 01:12 hi everybody! i have wa 5 but i don't understand my mistake. can anybody who knows some tests help me? Re: wa 5 Bahodir | {TUIT} | 29 Nov 2014 17:21 | | You are required to be just very attentive to solve this problem | Evgeniy[VVV] | 1804. The Machinegunners in a Playoff | 7 Feb 2015 17:16 | 1 | | | Помогите time limit wa8 | NikolosAvr | 1196. History Exam | 6 Feb 2015 20:26 | 2 | #include <iostream> int main() { long int i, n, m, z, s, k, a[16000], l, r, mid; std::cin >> n; k=0; for (i=0; i<n; i++) { std::cin >> z; if ((i!=0) && (z!=a[k])) { a[k]=z; k++; } if (i==0) { a[k]=z; k++; } } n=k-1; std::cin >> m; s=0; k=0; for (i=0; i<m; i++) { l=0; r=n; k=0; std::cin >> z; if ((z>a[0]) && (z<a[n])) while ((l<r) && (k<n-1)) { k=k+1; mid=(l+r)/2; if (a[mid]>z) r=mid; else if (a[mid]<z) l=mid; else if (a[mid]==z) break; } else if ((z==a[0]) || (z==a[n])) s++; if ((a[mid]==z) && (mid!=0)) s++; } std::cout << s; } Твоя программа слишком долго работает | | Please help me! Where I did error??? Cpp | alievv313-14 | 1787. Turn for MEGA | 5 Feb 2015 20:01 | 1 | #include<iostream> using namespace std; int main() { int k, n, S =0; cin >> k >> n; if (k, n >= 1 && k, n <= 100) { int *A = (int*)malloc(n*sizeof(int)); for (int i = 0; i < n; i++) { cin >> A[i]; if (!(A[i] >= 0 && A[i] <= 100)) break; } for (int i = 0; i < n; i++) S += A[i] - k; cout << S << endl; } return 0; } Edited by author 05.02.2015 20:02 | | C# решение. Runtime error | ptb1994 | 1811. Dual-SIM Phone | 5 Feb 2015 11:48 | 2 | Вот мой код. показывает Runtime на 4 тесте. не могу разобраться из-за чего. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication4 { class Program { static void Main() { bool sol; string s = Console.ReadLine(); string[] sp = s.Split(' '); int n = int.Parse(sp[0]); int m = int.Parse(sp[1]); int q = n + 1; int q2 = n + 2; int p1, p2, p3; int[, ,] mas = new int[q2, q2, q2]; // основной массив для работы. for (int i = 0; i < m; ++i) // заполнение массива с клавиатуры. { string a = Console.ReadLine(); string[] b = a.Split(' '); int[,] c = new int[1, 3]; // интовый массив вводимой строки for (int j = 0; j < 3; ++j) { c[0, j] = int.Parse(b[j]); if (j == 2) // когда массив с заполняется, вынимаем индексы и цены. { p1 = c[0, 0]; p2 = c[0, 1]; p3 = c[0, 2]; mas[p2, p1, 0] = p3; // заполняем 0-ой слой основного массива ценами. } } } for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { sol = true; for (int k = 1; k <= n; ++k) { if (mas[k, i, 0] == 0 & mas[k, j, 0] == 0) { mas[j, i, q] = 0; sol = false; } else { if (mas[k, i, 0] <= mas[k, j, 0] & mas[k, i, 0] != 0) { mas[j, i, k] = mas[k, i, 0]; } else { mas[j, i, k] = mas[k, j, 0]; } if (mas[j, i, q] < mas[j, i, k]) { if (sol) { mas[j, i, q] = mas[j, i, k]; } } } } if (mas[0, 0, 0] == 0) { mas[0, 0, 0] = mas[j, i, q]; } else { if (mas[j, i, q] > 0) { if (mas[0, 0, 0] >= mas[j, i, q]) { mas[0, 0, 0] = mas[j, i, q]; } } } } }
if (mas[0, 0, 0] < 1) { Console.WriteLine("No solution"); } else { Console.WriteLine(mas[0, 0, 0]); } Console.ReadKey(); } } } Я, конечно, не по теме, но зачем ты столько вложенности делаешь? В больших программах это же вообще ад. Например, else { if (mas[j, i, q] > 0) { if (mas[0, 0, 0] >= mas[j, i, q]) { mas[0, 0, 0] = mas[j, i, q]; } } } можно заменить на else if((mas[j, i, q] > 0)&&(mas[0, 0, 0] >= mas[j, i, q])) mas[0, 0, 0] = mas[j, i, q]; вообще одна-две строки. | | WA 18 | crc | 1085. Meeting | 4 Feb 2015 18:42 | 2 | WA 18 crc 4 Feb 2015 14:29 Ok I forgot about this: (if there are several numbers choose the minimal one) | | Ошибка в тестах. | Evgeniy | 1083. Factorials!!! | 4 Feb 2015 16:43 | 1 | Если изменить правило 2(если n делится на k) и вместо k умножить на 1, то все заработает. Определение 1. n!!…! = n(n−k)(n−2k)…(n mod k), если n не делится на k; n!!…! = n(n−k)(n−2k)…1, если n делится на k (знаков ! в обоих случаях k штук). | | Очень легкая задача. | Evgeniy[VVV] | 1680. The First Nonqualifying | 3 Feb 2015 17:27 | 1 | | | a question | alireza | 1001. Reverse Root | 3 Feb 2015 15:39 | 1 | who knows what the meaning of set of numbers is??? is it true that the user must specify how many numbers must be taken? Edited by author 03.02.2015 23:09 | | Ошибки при сдаче программ на Python 2.7 | Evgeny | | 3 Feb 2015 14:57 | 1 | Здравствуйте, У меня возникают постоянные ошибки при сдаче программ на Py2.7, например задача: 1293 N = input() B = input() A = input() print 2*N*A*B Выдает RE. Тот же код на Pascal сдается: var A, N, B: integer; begin read(N, A, B); write(2*N*B*A); end. И это только единичный случай, так со всеми. Я даже не могу задачку a + b решить =\ | | help me! I have TLE (java) | Zhassulan | 1048. Superlong Sums | 3 Feb 2015 14:38 | 2 | in.nextToken(); int n = (int) in.nval; byte ch1[] = new byte[n]; byte ch2[] = new byte[n]; while (n > 0) { in.nextToken(); ch1[n - 1] = (byte) in.nval; in.nextToken(); ch2[n - 1] = (byte) in.nval; n--; } int ost = 0; String answer = ""; for (int i = 0; i < ch1.length; i++) { int a = ost + ch1[i] + ch2[i]; if (a > 9) { answer = (a % 10) + answer; ost = a / 10; } else { answer = a + answer; ost = 0; } } out.print(answer); Could someone help with time optimization? | | Why Weiszfeld Algorithm doesn't converge fast enough for this problem? (-) | Al.Cash | 1815. Farm in San Andreas | 2 Feb 2015 19:59 | 1 | Edited by author 02.02.2015 20:11 |
|
|