Show all threads Hide all threads Show all messages Hide all messages |
Please HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | BAron | 1132. Square Root | 20 Nov 2007 01:21 | 3 |
Give me a few tests, please! Anybody, who had WA1 and then had AC, please help me!!!!!!!! Tests or any hints, please!!!!!!! Edited by author 24.06.2007 19:23 |
1 <= a, n <= 32767 is it true for all tests?? | wxsxg | 1132. Square Root | 16 Jun 2007 16:59 | 2 |
I got integer division by zero I want to know whether n==0 appears in the test? You had WA1 on this problem earlier. In what there was a mistake? Can at me same.... And please post some tests for this problem |
Please HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | BAron | 1132. Square Root | 16 Jun 2007 16:56 | 1 |
Give me a few tests, please! Anybody, who had WA1 and then had AC, please help me!!!!!!!! Tests or any hints, please!!!!!!! Edited by author 29.06.2007 09:00 |
Why I have WA#1 Please Help!!!!!!! | BAron | 1132. Square Root | 11 Jun 2007 21:35 | 1 |
Please post some tests!!! I dont know why my program have wa((( I think that algoritm is clear, but wa! Edited by author 12.06.2007 12:29 |
This can be solved without any deep math knowledge ! (and very fast) | Ostap Korkuna (Lviv NU) | 1132. Square Root | 7 Mar 2007 18:23 | 2 |
I've passed this problem with time 0.125 ! And the only mathematical conclusion I used is that when x is a square root then (n-x) is also. I am sure that the mathematical approach to this problem is also interesting (and probably harder than mine) but it was still very interesting for me to find the way to solve this problem without using of deep math knowledge. It is also interesting that my solution runs faster then some implementing the math approach :-) but still I use much more memory... http://acm.timus.ru/status.aspx?space=1&num=1132&author=30467 Thanks to mr. Medvedev for this problem. program Ural_1132; var i,j,x,p,q,n:longint; function power(a,b,c:longint):longint; var d,s:longint; begin d:=a;s:=1; while b>0 do begin if odd(b) then s:=(s*d) mod c; b:=b div 2;d:=(d*d) mod c; end; exit(s); end; begin read(n); for i:=1 to n do begin read(q,p);q:=q mod p; if (p=2) and (q=1) or (p<>2) and (power(q,(p-1) div 2,p)=p-1) then begin writeln('No root'); continue; end; if trunc(sqrt(q))=0 then begin x:=trunc(sqrt(q)); write(x); if p-x<>x then write(' ',p-x); writeln; continue; end; for j:=1 to (p-1) div 2 do begin x:=(j*j) mod p; if x=q then begin write(j); if p-j<>j then write(' ',p-j); writeln; break; end; end; end; end. Edited by author 07.03.2007 18:27 |
Why my program receives OLE ??? | Rizvanov++ de xXx | 1132. Square Root | 26 Apr 2006 11:37 | 1 |
...... ...... ...... int t,a,n,x0,x1; void main(){ #ifndef ONLINE_JUDGE *stdin=*fopen("1132.in","r"); #endif for(scanf("%d",&t);t>0;t--){ scanf("%d%d",&a,&n); x0=square_root_mod(a,n); if(x0){ x1=n-x0; if(x0<x1)printf("%d %d\n",x0,x1); else printf("%d %d\n",x1,x0); }else printf("No root\n"); } #ifndef ONLINE_JUDGE fclose(stdin); #endif } Edited by author 27.04.2006 11:29 Edited by author 27.04.2006 11:29 |
Hi | Ulzii | 1132. Square Root | 28 Jan 2006 12:27 | 1 |
Hi Ulzii 28 Jan 2006 12:27 Edited by author 30.01.2006 15:17 |
can someone tell me an easy way? | Czw's Brother | 1132. Square Root | 15 May 2004 13:11 | 1 |
|
Why I always got time exceeded?How to improve my program?I want to know the best algorithm. | Huang Yizheng | 1132. Square Root | 10 May 2004 16:12 | 5 |
I think that there is a simple formula that is going to work.... > I think that there is a simple formula that is going to > work.... I know the answer when (n mod 4)=3 The answer is +a^((n+1)/4), -a^((n+1)/4) But I don't know the answer when (n mod 4)=1 an efficient algorithm for this problem requires knowing very much of number theory: Legendre Symbols and other (i've found them on the web). You could search the web for quadratic residues modulo n... if not found, I cand send you "my" source... |
I don't understand the problem.Help,please! | Drizzt | 1132. Square Root | 21 Jul 2003 15:30 | 2 |
Could anyone tell me the problem in Chinese? |
'in the range (0,n-1) '?If a=1 n=7,the answer is '1 6 'or just '1' | Lin | 1132. Square Root | 15 Oct 2002 17:20 | 4 |
|
I wondered why all the accpeted programs are written in Pascal | mon | 1132. Square Root | 23 May 2002 20:21 | 2 |
my C++ solution always TE, while a direct translation of the C++ program in Pascal got accepted I try to solve it with C++ too, Thank you very much I will translation it to Pascal. I hope I will got accepted. |
Why 19 dosn't appear in the first line of sample output? | Malyshev Fedor | 1132. Square Root | 5 Nov 2001 19:21 | 5 |
We should print "2 15 19" (maybe something else), but in sample we have only 2 15. Why? if 19 appears, so 32 must do the same. In this prob, we must understand to output all the X satisfy the rule AND X <= N, that what i think about it :) QH@ > if 19 appears, so 32 must do the same. > In this prob, we must understand to output all the X > satisfy the rule AND X <= N, that what i think about it :) > > QH@ > > sqroot(a,n) is less then n. Remember that the result of modulo operations are always less than modulo!!! So sqroot(4,17) are less than 17 and of course, are positive integers. Author. "The number x is called a square root a modulo n (root (a,n)) if x*x = a (mod n)" so it's free to think that X can be in any range it wants ! So must put more rules that X <= N :-) QH@ Fixed Marat Bakirov 5 Nov 2001 19:21 |