Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
Страница 4 |
AC | Kirill~ | 1120. Сумма последовательных чисел | 31 дек 2021 10:46 | 1 |
AC Kirill~ 31 дек 2021 10:46 for (long double N = 1; N < sqrt(2*S)+3; N++) { } |
Use C++ | Конобейцев Иван Олегович | 1120. Сумма последовательных чисел | 8 дек 2021 15:39 | 1 |
Use C++ Конобейцев Иван Олегович 8 дек 2021 15:39 Bruteforse gets TL on Python but works on c++ |
For those who get WA 18 | MyCatWantsToKill | 1120. Сумма последовательных чисел | 26 дек 2020 11:23 | 1 |
Try: 2 Correct answer is 2 1 |
Cause of WA 9 | Ender | 1120. Сумма последовательных чисел | 24 ноя 2023 20:51 | 2 |
The probable cause of the error is the use of a floating point variable for computing of value a. Any floating point types have limited precision, and looks like some times it is not enough. Consider to use some integer types instead. |
as of Feb 2018, what is test #4? | LordPhantom | 1120. Сумма последовательных чисел | 3 фев 2018 01:39 | 1 |
N = int(input()) if N == 1: print(1,1) exit() for P in range(round(N**0.5)+1,0,-1): A = (2*N - P**2 + P) / (2*P) if A % 1 == 0: print(int(A),P) exit() |
If you use P(P+2A-1)=2N but have WA | IlushaMax | 1120. Сумма последовательных чисел | 30 мар 2017 20:40 | 2 |
Don't forget that not only P should be divider of 2N but P+2A-1 should be divider of 2N too. It was my mistake when I got WA 7 Thanks! Nikita UCSD Pascal 30 мар 2017 20:40 |
Please help me to continue my solution | IlushaMax | 1120. Сумма последовательных чисел | 29 апр 2016 01:03 | 1 |
I've got quadratic equation. It can be calculated if you know just what is arithmetical progression. What I should to know in maths to find max P (I found P from the equation). Edited by author 29.04.2016 01:05 |
почему WA 9 ? помогите | JamesBond_007 | 1120. Сумма последовательных чисел | 9 апр 2016 00:43 | 1 |
#include <iostream> #include <math.h> using namespace std; long long i, n, d; double a; int p; int main(){ cin >> n; n *= 2; p =(int) sqrt(n + 0.0); while(1){ a = (n - p * p + p + 0.0) / (2 * p); if(0 < a && a == (int) a && (p * p + 2 * a * p - p) == n) break; p --; } cout << (int)a << ' ' << p; } |
Test # 7 why? | AlexRad | 1120. Сумма последовательных чисел | 30 мар 2015 09:41 | 2 |
What is in test #7 ?? Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; var n = int.Parse(Console.ReadLine().Trim()); int a = 0; var p = (int)Math.Truncate(Math.Sqrt(n + n)); while (p > 1) { var s = n - p * (p + 1) / 2; if (s >= 0) { int rem; a = Math.DivRem(s, p, out rem); if (rem == 0) break; } p--; } a++; Console.WriteLine("{0} {1}", a, p); I got it! [code deleted] Edited by moderator 21.10.2019 23:03 |
Haha. I'll AC this problem :D | homealone1 | 1120. Сумма последовательных чисел | 27 мар 2015 11:56 | 1 |
O(sqrt(2 * N)) I have: A = (2 * N - P * P + P ) / ( 2 * P ) and P = [1, 2, 3, ..., sqrt(2 * N) + 3] :D I got AC ... |
WA on test nr.4 | Climova Olga | 1120. Сумма последовательных чисел | 24 фев 2015 13:12 | 1 |
Sorry for russian comments, I don't speak English well. Why WA? (system("pause"); is only for checking, of course) #include <iostream> using namespace std; int main() { unsigned long N, P, A; cin >> N; for (A = 1; A <= N; A++) // чтобы P было максимальным, начинаем с меньшего А { // прокручиваем P с N/A вниз, т.к. вроде бы это минимальное число с которого следует начинать for (P = N / A; P*A + P*(P - 1) / 2 > N; P--); if (P*A + P*(P - 1) / 2 == N) // если нашли - останавливаемся break; } cout << A << ' ' << P; system("pause"); return 0; } Edited by author 24.02.2015 13:16 |
WA #3 | Sirojiddin Abdukarimov | 1120. Сумма последовательных чисел | 5 ноя 2014 18:08 | 1 |
WA #3 Sirojiddin Abdukarimov 5 ноя 2014 18:08 |
WHY TLE ON TEST #9 MY COD IS SIMPLE | Лерник Казарян [RAU] | 1120. Сумма последовательных чисел | 14 ноя 2015 14:28 | 2 |
#include<iostream> #include<math.h> using namespace std; int main() { long long n,p,a=1; cin>>n; while(1) { p=(1-2*a+sqrt((2*a-1)*(2*a-1)+8*n))/2; if(2*n==2*p*a+p*(p-1)) { cout<<a<<" "<<p; break; } a++; } return 0; } On test #9 my solution got the same problem. Edited by author 14.11.2015 14:30 |
AC | Aguero -=Yaroslavl SU #2=- | 1120. Сумма последовательных чисел | 12 ноя 2013 16:44 | 1 |
AC Aguero -=Yaroslavl SU #2=- 12 ноя 2013 16:44 Я один раскладывал 2*n на всевозможные множители?) |
Страница 3 |
Why is this WA (#2)? | mbrc | 1120. Сумма последовательных чисел | 7 май 2014 13:12 | 2 |
#include <cmath> #include <cstdio> #include <iostream> using namespace std; typedef long long LL; int main() { LL N,A,P,up; cin>>N; up=(LL)ceil((1.00+sqrt(1.00+8.00*(double)N))/2.00); P=up; while (((2*N)%P)!=0) { P--; }
A=(((2*N)/P)-P+1)/2;
cout<<A<<" "<<P<<endl; } This is my code...but this is giving WA on #2. I can't understand the reason. It seems to give correct answer on the tests I do on my computer..?!
At first sight, I strongly suggest you to avoid operating repeteadly with floating points, the little errors will accummulate, and WA comes to the order. at second sight the logic is just not right. Look, I got the same algorithm that a dude with TLE at test9, but with a less complex break condition. private static int sq(long A,long N){ double aux= Math.sqrt( ((A*A)<<2) - (A<<2) + 1 + 8*N); int r = (int)aux; if ((double)r==aux) return r; else return -1; } public static void main (String[]args){ Scanner s=new Scanner(System.in); int N= s.nextInt(); long A=1,P=1,root=0; while (true){ root= sq(A,N); if (root==-1) A++; else{ P= (1-(A<<1)+root)/2; break; } } System.out.println(A+" "+(P)); } |
Input 4; 8.... Output? | barca | 1120. Сумма последовательных чисел | 29 окт 2012 20:00 | 2 |
If i input 4, what is answer? or if i input 8, what answer? |
Problem 1120 "Sum of Sequential Numbers" has been rejudged (+) | Sandro (USU) | 1120. Сумма последовательных чисел | 12 ноя 2011 18:02 | 2 |
New tests were added. 89 authors lost AC after rejudge. It's interesting. What kind of tests? |
Crash #9 | Alisher | 1120. Сумма последовательных чисел | 5 июн 2011 21:09 | 1 |
Could someone explain me why I've got Crash #9? I was trying all tests here but I've got nothing. #include <iostream> #include <fstream> #include <algorithm> using namespace std; int n, a[111111], b[111111], i, l = 0, sum, index = 1; int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif cin >> n; for(i=1;i<=100000;i++) { a[i] = a[i-1] + i; } while(true) { sum = a[index] - a[l] + l; if(sum == n) { int e = index - l + 1; if(l == 0) l++, e--; cout << l << " " << e; return 0; } if(sum > n) { l++; } else { index++; } } return 0; } Edited by author 05.06.2011 21:10 |
AC~~~happy~~ | zxy_snow | 1120. Сумма последовательных чисел | 7 авг 2019 04:27 | 3 |
I used some methods, got TLE || WA ...T T ... You can enumerate P . Think carefully and you will get a O(sqrt(n)) solution. Spend some time for enum, cause i don't wanna to calculate in float variables. So fun!) |
About Test 2 | rodge(Vologda ML) | 1120. Сумма последовательных чисел | 14 апр 2019 11:04 | 4 |
If you have WA 2 look this test 6 ans 1 3 10 ans 1 4 my programm gave for 6 ans 0 4 for 10 0 5 after changes about a1 = 0 AC.So a1 Not equal 0 It must be added to the statement. It IS in the statement: "Your program is to output two POSITIVE integers A and P separated with a space..." |