Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
Страница 2 |
what it test number 3 ??? | plague | 1120. Сумма последовательных чисел | 19 авг 2022 12:45 | 5 |
6 years have passed. But anyway, maybe this will help someone, the test number 3 is N = 1 5 years passed. anyway thanks. I has helped me. :) |
Help me, please? Why time limit exceeded 9? | AlexeyPechenin | 1120. Сумма последовательных чисел | 13 июн 2008 01:34 | 2 |
var k,n,m: Real; koren, p: Real; ok: Boolean; begin Readln(n); k:=0; p:=0; repeat ok:=false; m:=n+p; koren := (-1+sqrt(1+8*m))/2; if frac(koren) < 1e-18 then begin writeln(round(k+1),' ',round(koren - k)); ok:=true; end else begin k := k + 1; p:= (sqr(k) + k)/2; end; Until ok; End. i am also getting time limit exceeded for test 9 |
sos!! | lian lian | 1120. Сумма последовательных чисел | 9 окт 2008 14:35 | 2 |
sos!! lian lian 12 ноя 2007 18:38 i don`t understant what means "N = A + (A + 1) + … + (A + P − 1)."? i think: when A=2: 14=2+(2+1)+(2+2)+(2+3) P=? why was p=4 in the subject? please help me!!! Re: sos!! Nickolai Besschetnov 9 окт 2008 14:35 |
Please help..What is wrong? test 2 | Emil | 1120. Сумма последовательных чисел | 6 ноя 2007 20:22 | 1 |
#include <iostream> using namespace std; int main() {long int N=0,s=0; int a=0,p=0,kol=0,z=0; cin>>N; for (long int i=1;i<=N;i++) {s=s+i-1; if (s>N) break; else {if ((N-s)%i==0) {a=(N-s)/i;p=i;}}} cout<<a<<" "<<p; } |
Please, help... Lilo Dallas... Multipass... | knightmax | 1120. Сумма последовательных чисел | 17 окт 2007 20:56 | 1 |
WA on 5 test :( #include <stdlib.h> #include <string.h> #include <math.h> int main() { long n,i,a,n0; double fa; scanf ("%lli", &n); for (i=3*sqrt(n); i>0; i--) { fa=(n)/(double)i - ((double)i-1)/2.0; a=fa; /*printf("fa=%f a=%li p=%li\n",fa,a,i);*/ n0=((2*a+i-1)*i )/2; if (n0==n && a>0) {printf("%li %li\n", a, i); return 0;} } printf ("%li 1\n",n); return 0; } |
why i got wrong 4? | Andrei | 1120. Сумма последовательных чисел | 5 окт 2007 12:01 | 1 |
|
For those who got WA on test#2 | xcheng | 1120. Сумма последовательных чисел | 11 фев 2009 16:59 | 2 |
if n=1 the answer a=0 p=2 is wrong! The correct answer is a=1 p=1
Answer 1 1, but WA2 #include<iostream> #include<cmath> using namespace std; int main() { int n; int a; int p; int x,y; int i,j; int result=0; cin>>n; a=sqrt((float)n)+1; p=a; x=y=0; for (i=1;i<=a;i++) { result=0; for (j=1;j<=p;j++) { result+=(i+(j-1)); if (result==n) { if (y<j) { x=i; y=j; } } } } cout<<x<<" "<<y<<endl; return 0; } |
You can get it in just about O(sqrt(n)) | nickolas stoudemire | 1120. Сумма последовательных чисел | 14 ноя 2012 00:18 | 3 |
You can prove it with the knowledge of maths. Edited by author 22.08.2007 14:43 There is more strong aproximation. O(n^1/3) |
1120 and number 316227 | Snake | 1120. Сумма последовательных чисел | 6 окт 2007 19:36 | 2 |
Please explain me what the number 316227 means in the solution of this problem and in the programming at large.Thank you in advance. Edited by author 04.05.2007 14:55 2223 138 Edited by author 18.10.2007 20:32 |
Now i have AC | CHIDEMYAN SERGEY | 1120. Сумма последовательных чисел | 9 май 2007 17:56 | 4 |
[code deleted] please,help me!!!i<=?please,answer!Thank you very much!!!! Edited by author 27.04.2007 19:53 Edited by moderator 09.05.2007 16:04 Edited by author 09.05.2007 21:59 i get AC,But when i Go by different way!!!what wrong in this code? In your first 'for' you use sqrt(this calculates by formula Teylor) Sorry for my english Вобщем на английском не получается. Короче говоря ты в твоем основном цикле используешь квадратный корень а в C++ он считается формулой тейлора т.е. цикл состоящий как минимум 50 шагов да еще то что все считаеш в double => для числа 1'000'000'000 ты выполняешь не 1'000'000'000 а 50'000'000'000 шагов ВОТ и поэтому TLE#9 УСЕ. Спасибо.Кстати я получил AC,но решил по-другому!!!У Эдгара кажется получилось оптимизировать этот код!!! |
WHY WA 10# ? | Razvan Brezulianu | 1120. Сумма последовательных чисел | 20 апр 2007 13:24 | 1 |
my code! please help! thanks! #include<stdio.h> #include<math.h> long i, j, n, div, p, a; int main() { scanf("%ld", &n); for(i = sqrt(n); i >= 1; i--) if(n % i == 0) { p = i * 2; a = n / (p / 2) - (p - 1); if(a % 2 == 0 && a / 2 >= 0) { a = a / 2; i = 0; } } printf("%ld %ld\n", a, p); return 0; } Edited by author 20.04.2007 13:25 Edited by author 20.04.2007 13:25 |
WA test 8? | Sergio Marquez | 1120. Сумма последовательных чисел | 29 авг 2006 12:01 | 1 |
somebody can help me? or give me more tests. WA test 8. |
Help, plz.:) | MiR | 1120. Сумма последовательных чисел | 6 авг 2006 15:51 | 3 |
If n=1, a=1 and p=1(1+0) If n=3, a=1 and p=2(1+(1+1)) But if n=2? What should I output in this case? Thanks.
a=2 p=1 And what was the trouble in? |
what is test#2? I got wa | serendipity | 1120. Сумма последовательных чисел | 31 июл 2006 12:20 | 1 |
|
Why Complation Error? | Echos (Alexey Akulshin) | 1120. Сумма последовательных чисел | 27 июл 2006 19:18 | 3 |
[code deleted] Edited by moderator 28.07.2006 10:35 sqrt(D) -> sqrt((double)D) |
PLEASE HELP!!! WA2 | DonNTU Team (Akulshin, Belikov, Trofimenko) | 1120. Сумма последовательных чисел | 31 июл 2006 12:12 | 2 |
What's wrong? I think, that my program is right: [code deleted] Edited by moderator 28.07.2006 10:35 me too,wrong answer on test#2 !!! |
what is wrong!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! help me!! | matkir_ssau | 1120. Сумма последовательных чисел | 4 янв 2006 01:50 | 1 |
test #9 help,help please anybody please give me test #9 {================================} var q1,q,k,p,y,z:real; n,i:longint; begin read(n); q:=0; q1:=0; for i:=round(sqrt(n)*1.2353) downto 1 do begin y:=n/i; k:=n/(i+0.5); if (frac(y)=0) and (frac(y/2-0.5)=0) and ((n/y+0.5-y/2)>0) then if q<y then q:=y; if (frac(k)=0) and (frac(k/2)=0) and ((n/k+0.5-k/2)>0) then if q1<k then q1:=k; end; if (q>q1) then if (q*q+(2*(n/q+0.5-q/2)-1)*q=2*n) then begin writeln((n/q+0.5-q/2):0:0,' ',q:0:0);z:=1;end; if (q<q1) then if (q1*q1+(2*(n/q1+0.5-q1/2)-1)*q1=2*n) then begin writeln((n/q1+0.5-q1/2):0:0,' ',q1:0:0);z:=1;end; if z<>1 then writeln(n,' ',1); end. Edited by author 04.01.2006 17:30 |
Full search - AC! 0.015 201 КB | Akshin Salimov | 1120. Сумма последовательных чисел | 30 дек 2005 17:02 | 1 |
|
What is test case value for 7 | Karthick P | 1120. Сумма последовательных чисел | 15 ноя 2007 16:46 | 2 |
The solution for the input "7" is whether "3 2" or not Yes! i have this result too |
Why Compliation Error?? | Anne_Deb | 1120. Сумма последовательных чисел | 5 авг 2005 20:44 | 2 |
plz check my program... #include<stdio.h> #include<math.h> int main() { long n,a,p,x,chk=0,sum=0; scanf("%ld",&n); for(x=sqrt(n);chk==0;x++) { if(x*(x+1)/2>n) { break; } } for(chk=0;x<=n/2+1;x++) { for(p=1;sum<n;p++) { sum+=x+1-p; if(sum==n) { a=x+1-p; x=n/2+2; chk=1; break; } } sum=0; } if(chk==1) printf("%ld %ld",a,p); return 0; } Your source have some problem about sqrt fuction. I think you have to use sqrt((double)n); |