Common BoardMy AC program works very slowly on the following test: 12 256 256 256 256 256 256 256 256 256 256 256 1 Can you add it to the testset? and this one: 12 22 22 20 20 20 20 20 20 20 20 20 156 one more 12 159 205 210 159 218 66 256 38 135 47 249 169 I am getting WA in test#10. Can anyone help me??? Thanks in advance. :) can you help me? fail is on fifth test... mikael@ubuntu:~/Desktop$ ./xx 1 1 mikael@ubuntu:~/Desktop$ ./xx 0 10 mikael@ubuntu:~/Desktop$ ./xx 2 2 mikael@ubuntu:~/Desktop$ ./xx 3 3 mikael@ubuntu:~/Desktop$ ./xx 4 22 mikael@ubuntu:~/Desktop$ ./xx 5 5 mikael@ubuntu:~/Desktop$ ./xx 6 23 mikael@ubuntu:~/Desktop$ ./xx 8 24 mikael@ubuntu:~/Desktop$ ./xx 9 33 mikael@ubuntu:~/Desktop$ ./xx 10 25 mikael@ubuntu:~/Desktop$ ./xx 20 45 mikael@ubuntu:~/Desktop$ ./xx 25 55 mikael@ubuntu:~/Desktop$ ./xx 30 56 mikael@ubuntu:~/Desktop$ ./xx 45 59 mikael@ubuntu:~/Desktop$ ./xx 60 256 mikael@ubuntu:~/Desktop$ ./xx 105 357 mikael@ubuntu:~/Desktop$ ./xx 108 269 mikael@ubuntu:~/Desktop$ Mikael, according your outputs: 2->2, 3->3, and why is 4->22? Maybe 4->4 is right answer? if you will not send me the answer of this problem i will kick you out of the contest.!! fuc* you! :) if you will not send me the answer of this problem i will kick you out of the contest.!! Edited by author 16.09.2012 00:41 Edited by author 16.09.2012 00:41sorry I was joking. :) Edited by author 16.01.2014 13:50 Please help me #include <iostream> #include <math.h> using namespace std; int main(int argc, const char * argv[]) { double stack[1000]; int index = 0; while (cin >> stack[index]) { index++; }
index--; for (; index > 0; index--) { printf("%.4lf\n", sqrt(stack[index])); }
} There will be more than 1000 numbers. double stack[1000]; - Your error is here Use dynamic storage like stl vector #include <stdio.h> #include <math.h> #include <vector> using namespace std; int main(int argc, const char * argv[]) { vector <double> stack; int index = 0;
while (scanf("%lf", &stack[index++]) != EOF) {
}
for (index--; index > 0; index--) { printf("%.4lf\n", sqrt(stack[index])); }
} still wrong answer, access violation. please help me You cannot access stack[index] since its size is 0. Use an intermediary variable for the read number, and then use stack.push_back(x). Use stack.size() to retrieve the number of elements in the stack. Or you can use a <list> instead of <vector>, and use push_front, so that in the end, you don't need to loop in reverse order. Take a look on these STL containers, to get familiarized with them: http://www.cplusplus.com/reference/vector/vector/push_back/http://www.cplusplus.com/reference/list/list/push_front/ Edited by author 15.01.2014 17:11 Edited by author 15.01.2014 17:11using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace _1542 { public class word { public string line; public int count; public word(string g="", int f=0) { line=g; count =f; } } class sortim: IComparer<object > { public int Compare(object x, object y) { word a, b; a = (word)x; b = (word)y; if (a.count < b.count) return 1; else if (a.count > b.count) return -1; else return String.Compare(a.line, b.line); } } class Program { static void Main(string[] args) { sortim sort = new sortim(); int n = Convert.ToInt32(Console.ReadLine()); word[] wor = new word[n]; for (int i = 0; i < n; i++) { string[] temp = Console.ReadLine().Split(' '); wor[i] = new word(temp[0], Convert.ToInt32(temp[1])); } int g= Convert.ToInt32(Console.ReadLine()); for (int i = 0; i < g; i++) { string request = Console.ReadLine(); word[] select = Array.FindAll(wor, e => e.line.Substring(0,request.Length)==request ); Array.Sort(select, sort); for (int i1 = 0; i1 < Math.Min(select.Length,10); i1++) { Console.WriteLine(select[i1].line); } if (i!=g-1) Console.WriteLine(); } } } } p - это суммарная сила всплеска по всем заклинаниям, которую могут выдержать волшебники, или максимальная сила всплеска за одно заклинание (каждый раз одна и та же)? ENGLISH, please Who is know test 22???? Maybe in 22 test : you can survive if [count_destroyable_coins] * [power_spell] <= [you_health]. Check your code : "<=" , not "<". Good Luck. I don't understand. So why in the test case the coins with value 4 are not killed? What am I missing? If you use spell power 4 you will destroy two coins, so the strikes back will be 2 * 4 = 8 and you can't survive The question was: is the survival limit an accumulation of all previous spells, or is it just per spell? Please somebody provide some more test cases ... since X,M,Y in [0,1000]... power(X,N) is very large, we can't to calculate! f(N) = X^N mod M = Y then, X^N=k*M+Y f(N+1) = X^(N+1) mod M = (X^N*X) mod M =(k*M*X+Y*X) mod M =Y*X mod M =f(N)*X mod M example for X,M,Y is 2,6,4. f(0)=2^0 mod 6 = 1 f(1)=f(0)*2 mod 6 = 2 f(2)=f(1)*2 mod 6 = 4 (ok) f(3)=f(2)*2 mod 6 = 2 f(4)=f(3)*2 mod 6 = 4 (ok) f(5)=f(4)*2 mod 6 = 2 f(6)=f(4)*2 mod 6 = 4 (ok) thanks. thanks for idea! But there is a mistake. Input format is N, M, Y. It seems that it is DP problem. So, you must define recursive function f(x, n, m) = { 1%m | if n is 0 f(x, n-1, m)*x % m | else } And call it for every x from 0 to m-1. Algorithm complexity is O(n^2) So, at worst case there will be at about 1 000 000 iterations. But it works. Thanks for idea! Good luck ;) misprint должен состоять также их одной строки их->из Edited by author 12.01.2014 22:05 If your output format differs from the required output format (even by one space).....you will get WA. So be careful..... suffix array + HESH = WA 67 , why please give me some test Edited by author 08.11.2013 17:06 Try to avoid hashes does size of T equal to n or not? could you give me your email ? I will send you my code and you will give me your advice a have got WA67 when i use polynomial hash module to multiple of two (up to 96bit hash). try to modify your hash, or use another algo. ( my ac solution uses suffix array with hash ;) ) static void Main() { string[] tokens = Console.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); //Console.ReadLine().Split(' ');
int i; double r;
for (i = tokens.Length - 1; i > -1; i--) { r = Math.Round(Math.Sqrt(int.Parse(tokens[i])), 5);
Console.WriteLine("{0:F4}",r); }
} i try so much ... in the beginning but i haven't got ACCEPTED ... But now I have got accepted. i use in the beginning a %= n. after my program is accepted. Edited by author 12.01.2014 15:15 C# using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace _1413 { class Program { static void Main(string[] args) { System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; string[] temp = Console.ReadLine().Split('0'); string l = temp[0]; decimal k = 0,x=0,y=0; decimal sqrt =Convert.ToDecimal( Math.Sqrt(2))/2; for (int i = 1; i < 10; i++) { k = l.Split(new string[]{ i.ToString() }, 1000000000, StringSplitOptions.None).Length - 1; if (i == 1){ x -= k * sqrt;y-=k*sqrt;} if (i == 2) y -= k; if (i == 3) { x += k * sqrt; y -= k * sqrt; } if (i == 4) x -= k; if (i == 6) x += k; if (i == 7) { x -= k * sqrt; y += k * sqrt; } if (i == 8) y += k; if (i == 9) { x += k * sqrt; y += k * sqrt; } } Console.WriteLine("{0:F10} {1:F10}", x, y); } } } It's better to count angles like there --> arccos((x1*x2+y1*y2)/(rast(x1,y1)*rast(x2,y2))); Be carefull when cos is ~1. Good luck! This task can be solved without any operations with float values. Just "*", "+" and "compare" operations with Integers. Can anyone explain this problem? I didn't understand why we have L, I think we don't need it, or what should we find at all. or what does it mean, that the width is zero there. I think l have solved this problem,but i got WA on test #2. For my solution replacing integer 32-bit with 64-bit integer helped, and all tests passed. There is a 32-bit integer overflow in test #2. help plz,thx! Don't know, but replacing int->int64_t (32-bit integers with 64-bit integers) helped for my solution, there is some integer overflow in test #2. Where is wrong? This is MY SOLVe!!! program MEGA; {$APPTYPE CONSOLE} uses SysUtils; var i,n,k:integer; a:array[1..100] of int64; m:int64; begin read(n,k); if n=2 then begin writeln((k-1)*k); halt(0); end; if n=3 then begin writeln((k-1)*k*k-k+1); halt(0); end; a[3]:=k-1; m:=k-1; for i:=4 to n do begin m:=m*(k-1); a[i]:=a[i-1]+(i-2)*m; end; m:=k-1; for i:=1 to n-1 do m:=m*k; writeln(m-a[n]); end. I had a wrong answer in test #2 due to integer overflow. Replacing 32-bit integers with 64-bit integers helped and all tests passed (only in my solution, I didn't test yours). i am getting correct answers for the cases posed here but i am getting WA on 2 ...?? can anyone figure it out..?? I replaced all 'int' with 'int64_t' type in my program and all tests passed, and before I had wrong answer in test #2, hence there is some integer overflow in test #2. |
|