Общий форумprogram Project1; {$APPTYPE CONSOLE} var sym : char; a, b : AnsiString; la, lb, i : qword; l, m, n : byte; c : array of byte; begin read(sym); repeat a:=a+sym; read(sym); until (sym=' '); readln(b); la:=length(a); lb:=length(b); if la>lb then setlength(c, la) else setlength(c, lb); i:=0; n:=0; repeat i:=i+1; if la>0 then l:=ord(a[la])-48 else l:=0; if lb>0 then m:=ord(b[lb])-48 else m:=0; c[i]:=l+m+n; n:=c[i] div 10; c[i]:=c[i] mod 10; if la>0 then la:=la-1; if lb>0 then lb:=lb-1; until (la<=0) and (lb<=0) and (n=0); while (i>0) do begin write(c[i]); i:=i-1; end; end. =) (= just high precision, but a bit slow Or just use unsigned long long in C... I know that this problem can be solved by this: program Project1; {$APPTYPE CONSOLE} uses SysUtils; var a, b : longint; begin read(a,b); write(a+b); end. I did it just for fun)))) ce ai? nu merge submit`u? Strange... Solving this problem I thought that rows are numbered from bottom to top. Edited by author 18.02.2010 20:17 Why I got MLE#3? I'm using 1 int[M][3] matrix to store the edges, 3 short[N+1] arrays for Union-find, and an additional short[N] to store the resulting spanning tree. Bug in qsort. Edited by author 18.02.2010 15:19 why it is wrong? "An arithmetic expression in D++ is always opened by "(", is closed by ")" and may contain any of the following symbols: "=+-*/0123456789)("" arithmetic expression is opened by '(',may contain '*'and closed by ')'.so "(*)" can seen as a right arithmetic expression. anyone can answer me?? my AC'ed solution says that (*) is NOT a legal expression. Either the test set does not have such things, or judges do not consider (*) to be an arithmetic expr An arithmetic expression can't start with a pair of symbols "(*" In my opinion, (*) is valid COMMENTARY - it's opened by (* and closed by *) ; I think we need to add "and these two pairs of symbols should not intersect" to this phrase in statement - " A comment is always opened by a pair of symbols "(*" and is closed by a pair of symbols "*)" , otherwise (*) is YES for sure. Edited by author 16.02.2010 13:52 In my opinion, (*) is valid COMMENTARY - it's opened by (* and closed by *) ; I think we need to add "and these two pairs of symbols should not intersect" to this phrase in statement - " A comment is always opened by a pair of symbols "(*" and is closed by a pair of symbols "*)" , otherwise (*) is YES for sure. You is very crazy man :) I think, that you never write syntax analyzer for languages. You "additional condition" is obvious for all, that ever write syntax analyzers, but not for you. :) This problem is about syntax analyzer , NOT working with any string and substrings. Edited by author 16.02.2010 21:12Dear Team, It is really very good support by you. But please, look at the problem 1001-in java. There might be problem in compiler-there is no one who solved this question in java. I will include my answer too.: import java.util.Scanner; public class second{ public static void main(String[] args) { Scanner s = new Scanner(System.in); double[] arr2=new double[200000]; int i=0,k=0; do{ arr2[k]=s.nextDouble(); k++; } while(s.hasNext()); for(i=k;i>0;i--){ System.out.printf("%.4f\n",Math.sqrt(arr2[i-1])); } } } Are you kidding :) Many people solved this problem in Java. I am among them. Edited by author 16.02.2010 21:05 My solution use emulation with some heuristic conditions (for avoiding deadlock). Solution is o(n). Some test: 1 output 3 0 2 1 -------- 2 output 8 1 3 4 2 0 1 3 2 -------- 3 output 15 2 4 5 3 1 0 2 4 6 5 3 1 2 4 3 -------- 4 output 24 3 5 6 4 2 1 3 5 7 8 6 4 2 0 1 3 5 7 6 4 2 3 5 4 -------- 5 output 35 4 6 7 5 3 2 4 6 8 9 7 5 3 1 0 2 4 6 8 10 9 7 5 3 1 2 4 6 8 7 5 3 4 6 5 Please tell me. Thanks. "If there are many solutions, you may output any of them." #include <iostream> using namespace std; #include <math.h> struct Point { long double x; long double y; }; struct Point2 { int number; long double angle; }; void insertSort(Point2 ** a, long size) { Point2 * x; long i, j; for ( i=0; i < size; i++) { // цикл проходов, i - номер прохода x = a[i];
// поиск места элемента в готовой последовательности for ( j=i-1; j>=0 && (a[j]->angle < x->angle); j--) a[j+1] = a[j]; // сдвигаем элемент направо, пока не дошли // место найдено, вставить элемент a[j+1] = x; } } /* int compare( const void *arg1, const void *arg2 ) { if(((Point2*)arg1)->angle>((Point2*)arg2)->angle) return -1; else return 1;
}*/ int main() {
int n; cin>>n; Point * arr = new Point[n]; long double min_a=0; int min_ai; for(int i = 0;i<n;++i) { cin>>arr[i].x; cin>>arr[i].y; if((!i)||arr[i].y<min_a) { min_a = arr[i].y; min_ai = i; } } cout<<min_ai+1<<" "; Point2 ** arr2 = new Point2*[n-1]; int j = 0; long double xx = arr[min_ai].x; long double yy = arr[min_ai].y; for(int i = 0;i<n;++i) { if(i!=min_ai) { arr2[j] = new Point2; arr2[j]->number = i; arr2[j]->angle = (arr[i].x - xx)/sqrt(pow(arr[i].x-xx,2)+pow(arr[i].y-yy,2)); ++j; } } //qsort(arr2,n-1,4,compare); insertSort(arr2,n-1); cout<<arr2[(n-1)/2]->number+1<<endl; return 0; } I don't know why, but qsort sorts them wrongly (I commented part that is qsort and changed it with simple O(n^2) sorting and got AC... But could tell me, what's so wrong with this qsort? I think I could get a better time with it. In this task qSort works very quick :) But you time is not very bad ;) If you will use sort from <algortihm>, you will get AC. http://www.cplusplus.com/reference/clibrary/cstdlib/qsort/I changed int compare( const void *arg1, const void *arg2 ) { if(((Point2*)arg1)->angle>((Point2*)arg2)->angle) return -1; else return 1; to int compare( const void *arg1, const void *arg2 ) { if(((Point2*)arg1)->angle>((Point2*)arg2)->angle) return 1; else return -1; according to conditions presented in the href above. On my computer I get answer "1 4" on first test, but on server in gets WA #1. /* qsort example */ #include <stdio.h> #include <stdlib.h> int values[] = { 40, 10, 100, 90, 20, 25 }; int compare (const void * a, const void * b) { return ( *(int*)a - *(int*)b ); } int main () { int n; qsort (values, 6, sizeof(int), compare); for (n=0; n<6; n++) printf ("%d ",values[n]); return 0; } It is very very strange. QSort does not work here. Use Merge or Heap sort. The only email I found on this is site is timus_support@acm.timus.ru, which when I send an email to, I got mail return: The original message was received at Sun, 24 Jan 2010 15:38:57 +0500 from mail-pw0-f57.google.com [209.85.160.57] ----- The following addresses had permanent fatal errors ----- judge_mailbox@busin.usu.ru (reason: 550 5.1.1 User unknown) (expanded from: <timus_support@acm.timus.ru>) ----- Transcript of session follows ----- 550 5.1.1 judge_mailbox@busin.usu.ru... User unknown Final-Recipient: RFC822; timus_support@acm.timus.ru X-Actual-Recipient: RFC822; judge_mailbox@acm.busin.usu.ru Action: failed Status: 5.1.1 Diagnostic-Code: X-Unix; 550 5.1.1 User unknown Last-Attempt-Date: Sun, 24 Jan 2010 15:39:05 +0500 ---------- Forwarded Message ---------- From: Nat Pavasant <n...@gmail.com> To: timus_support <timus_support@acm.timus.ru> Date: Sun, 24 Jan 2010 17:38:44 +0700 Subject: ... Any answer? Try email judge_school (at) mail.ru Very beautiful problem and very easy to solve it using simple geometric methods of working with vectors and points. Pay attention to output: In the first three lines output the coordinates of the points put INSIDE the triangle. In the following three lines output the coordinates of the points put OUTSIDE the triangle. Edited by author 15.02.2010 18:39 Captain obvious with us! Alex, Stop flooding, plz. #include <iostream> #include <math.h> using namespace std; int main() { int n,s; cin>>n; if(n%10==7) s=int((n-1)*log((double)2)/log((double)10)); else s=int(n * log((double)2)/log((double)10)); cout<<s<<endl; return 0; } What is lacking in terms? What could I forget? My old accepted program does not pass some tests. Maybe it concerns only my solution, however it would be quite good to add these tests. With recent changes to statement sample became wrong; I think sample input should now look like: BID 0.01 BID 10000.00 BID 5000.00 BID 5000.00 SALE 7000.00 3 DEL 5000.00 SALE 3000.00 3 SALE 0.01 3 QUIT , am I right? We have replaced "exactly 2 digits" by "at most 2 digits" in the problem statement. Thank you. I think, that tests for this problem are bad. For test 3 3 3 2 1 my AC program gives answer 2, while answer 1 is correct. P.S. My first AC solution is incorrect, but i hope, that my second AC solution is correct. My program worked this tests, but WA2? 14 1 1 3 3 0 2 2 2 2 0 2 2 6 1 -1 1 5 6 5 0 2 2 0 3 -1 1 5 6 5 0 2 2 -4 0 -1 1 5 6 5 0 2 2 6 7 -1 1 5 6 5 0 2 2 5 7 -1 1 4 6 5 0 1 1 6 6 2 2 3 3 4 4 1 1 6 6 2 4 3 3 4 2 1 1 2 2 -1 -1 -1 -2 -2 -1 1 1 3 3 4 6 2 2 6 4 1 1 3 3 4 6 1 2 6 4 1 1 3 3 4 6 1 2 7 4 1 1 2 2 1 3 3 3 3 1 1 1 1 5 0 8 1 2 3 2 Answer: 4.576491 5.019765 5.398346 6.324555 10.676619 10.605551 7.071068 7.634414 1.414214 8.993230 8.993230 9.162278 1.414214 5.841619 Test: 1 1 1 5 2 1 2 5 1 0 3 Answer: 5.000000 Remember, that plain text can contain ANY symbols (digits, signums), except ( or ) (123)123(123) - YES -5/7 + -5/7 ###### -1 3/7 0 / -1 25/31 ###### 0 1/7 * -49 7/9 ##### -7 1/9 -11 1/8 / -11 1/8 ##### 1 for test 1/7 * -49 7/9 ##### -7 1/9 answer -6 8/9 is rigth? |
|