Show all threads Hide all threads Show all messages Hide all messages |
Cause of WA 9 | Ender | 1120. Sum of Sequential Numbers | 24 Nov 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. |
what it test number 3 ??? | plague | 1120. Sum of Sequential Numbers | 19 Aug 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. :) |
AC | Kirill~ | 1120. Sum of Sequential Numbers | 31 Dec 2021 10:46 | 1 |
AC Kirill~ 31 Dec 2021 10:46 for (long double N = 1; N < sqrt(2*S)+3; N++) { } |
Use C++ | Конобейцев Иван Олегович | 1120. Sum of Sequential Numbers | 8 Dec 2021 15:39 | 1 |
Use C++ Конобейцев Иван Олегович 8 Dec 2021 15:39 Bruteforse gets TL on Python but works on c++ |
For those who get WA 18 | MyCatWantsToKill | 1120. Sum of Sequential Numbers | 26 Dec 2020 11:23 | 1 |
Try: 2 Correct answer is 2 1 |
What is the answer for 111111113 | Samvel | 1120. Sum of Sequential Numbers | 15 Sep 2020 17:25 | 6 |
My AC solution returns 55555556 2 Hi, Mine is same as Howard Liu i.e. 55555556 2 Varun > My answer is 61313 68558 This is an answer for 6553562057. I also get 55555556 2 for 111111113. |
AC~~~happy~~ | zxy_snow | 1120. Sum of Sequential Numbers | 7 Aug 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. Sum of Sequential Numbers | 14 Apr 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..." |
as of Feb 2018, what is test #4? | LordPhantom | 1120. Sum of Sequential Numbers | 3 Feb 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. Sum of Sequential Numbers | 30 Mar 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 Mar 2017 20:40 |
WA9 ! what's wrong with my code !?! my code here | Farhad Ghasemi | 1120. Sum of Sequential Numbers | 15 Feb 2017 18:05 | 3 |
#include<iostream> #include<math.h> using namespace std; int main() { int n; int p; double a; int i; cin>>n; int flag; for(p=sqrt(n*2);p>0;p--) { a=(double)n/p-(double)(p-1)/2; if(a==(int)a && a>0) { cout<<a<<" "<<p; return 0; }
} cout<<n<<" "<<1; return 0; } Edited by author 09.10.2008 14:39 cout << (int)a << " " << p; :) |
Please help me to continue my solution | IlushaMax | 1120. Sum of Sequential Numbers | 29 Apr 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. Sum of Sequential Numbers | 9 Apr 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; } |
WHY TLE ON TEST #9 MY COD IS SIMPLE | Лерник Казарян [RAU] | 1120. Sum of Sequential Numbers | 14 Nov 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 |
Test # 7 why? | AlexRad | 1120. Sum of Sequential Numbers | 30 Mar 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. Sum of Sequential Numbers | 27 Mar 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. Sum of Sequential Numbers | 24 Feb 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. Sum of Sequential Numbers | 5 Nov 2014 18:08 | 1 |
WA #3 Sirojiddin Abdukarimov 5 Nov 2014 18:08 |
Why is this WA (#2)? | mbrc | 1120. Sum of Sequential Numbers | 7 May 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)); } |
AC | Aguero -=Yaroslavl SU #2=- | 1120. Sum of Sequential Numbers | 12 Nov 2013 16:44 | 1 |
AC Aguero -=Yaroslavl SU #2=- 12 Nov 2013 16:44 Я один раскладывал 2*n на всевозможные множители?) |