| Show all threads Hide all threads Show all messages Hide all messages |
| A simple way to correct solution | olpetOdessaONU [1 2/3] | 1133. Fibonacci Sequence | 18 Feb 2015 14:27 | 4 |
If you use formula in C++, you don't need the long arithmetics. Use long double and you'll get AC. i used long double, 2 4 6 29 -1000 but my answer is -6.00693e+208, is it correct or not? you should turn off siencetific notation My approach goes like this: lets choose a big random prime P > 10^16, and calculate F_(i+1)%P. |
| bits/stdc++.h (TLE) vs stdio.h (AC) | Dijkstraido | 1048. Superlong Sums | 17 Feb 2015 01:48 | 1 |
bits/stdc++.h -> TLE on Test #4 cstdio -> TLE on Test #4 stdio.h -> AC Compiled with: G++ 4.9 C++11 Can anyone give an explanation? |
| why my code got WA #2 ? | vladimir | 1049. Brave Balloonists | 15 Feb 2015 23:30 | 2 |
var podschet,a,b,i:integer; begin a:=1; for i:=1 to 10 do begin readln(b); a:=a*b; end; for i:=1 to a do begin if a mod i=0 then podschet:=podschet+1; end; if podschet>9 then podschet:=podschet div 10; writeln(podschet); end. Edited by author 11.12.2014 15:46 Mistake is in this line: if podschet>9 then podschet:=podschet div 10; To take last digit you should be using mod instead of div. Edited by author 15.02.2015 23:31 Edited by author 15.02.2015 23:31 |
| Work fine on my computer, returns "wrong answer" here (Python 3.3). | ipeterov | 1001. Reverse Root | 15 Feb 2015 23:30 | 2 |
Here's my code: import math a = input() a = a.replace('\n', ' ') a = a.split() a.reverse() for i in a: print(math.sqrt(float(i))) Edited by author 10.05.2014 16:59 What we are inputting is a stream of inputs, that may contain '\n'. On the other hand, input() cannot contain newline character. |
| problem 1068 wrong answer?? | sar | 1068. Sum | 15 Feb 2015 21:02 | 1 |
#include<iostream> using namespace std; int main() { long int N,i,sum=0; cin >> N; if (N > 10000 || N < -10000) { cout<<sum; return 0; } if(N>0) for(i= N; i>= 1; i-- ) sum=sum+i; if(N<0) for(i= N; i<=1; i++) sum=sum+i; cout<<sum; } |
| The projection? | GeoSer | 1388. Photo | 15 Feb 2015 14:40 | 1 |
What kind of projection? Orthographic or perspective? Edited by author 15.02.2015 14:43 |
| whats wrong with my codes?? WA #10 | mehdi_wm | 1787. Turn for MEGA | 15 Feb 2015 12:01 | 1 |
import java.util.*; public class TurnForMEGA { public static void main(String[] args) { Scanner in=new Scanner(System.in); int k=in.nextInt(); int n=in.nextInt(); int sum=0,temp=0; int result=0; int[] array =new int[100]; for(int i=0;i<n;i++){ array[i]=in.nextInt(); } for(int i=0;i<n;i++) { temp=array[i]-k; if(temp>0) { array[i+1]+=temp; } } result=array[n-1]-k; if(result<=0) { result=0; } System.out.print(result); }
} Edited by author 15.02.2015 12:16 Edited by author 15.02.2015 12:16 |
| all 3 digit numbers would be lucky | nikhil | 1044. Lucky Tickets. Easy! | 15 Feb 2015 05:18 | 3 |
according to the language of question sum of 1st 3 digits must be equal to the sum of last three digits for a number to be lucky. so am i missing some point? please help! According to statement digit count must be divisible by 2, source: "Output should contain a number of tickets such that the sum of the first half of digits is equal to the sum of the second half of digits." |
| WA#3 : use long long, sum > n*3 | ACSpeed | 1688. Team.GOV! | 12 Feb 2015 22:24 | 2 |
|
| WA c++ help | Barbs | 1607. Taxi | 12 Feb 2015 18:46 | 1 |
#include <iostream> using namespace std; int main(){ int a,b,c,d,k=0; cin >> a >> b >> c >> d; while(a<c){ if(k==0){ k = 1; a += b; cout << a << " "; } else { k = 0; c -= d; cout << c << " "; } } cout << a ; return 0; } |
| Accepted sqrt_decom && binary_search && quick sort 0.765 | Temirbay Miras | 1613. For Fans of Statistics | 12 Feb 2015 10:15 | 1 |
|
| WA3 | zimpha | 2041. Nanomatryoshkas | 12 Feb 2015 07:35 | 1 |
WA3 zimpha 12 Feb 2015 07:35 can anyone provides some testcases? |
| Just use brute force, it works. | gopher nice byte | 1005. Stone Pile | 12 Feb 2015 03:36 | 1 |
|
| FUNNY SOLUTION (VIEWER DISCRETION IS ADVISED) | cena | 1044. Lucky Tickets. Easy! | 11 Feb 2015 23:52 | 3 |
#include <iostream> using namespace std; int main() { int arr[4] = {10, 670, 55252, 4816030}; short m; cin >> m; cout << arr[m / 2 - 1]; return 0; } //hey; can you guess how i got these values?(think of the simplest solution) Edited by author 15.02.2013 04:31 if we are not too creative to calculate this on paper and there is no forum to take solution just do backtracking it works fine 1 second and something #include <iostream> using namespace std; int x[10], n, cont = 0; void back(int k) { if(k == n) { int s1 = 0, s2 = 0; for(int i = 0; i < n / 2; i++) { s1 += x[i]; } for(int i = n / 2; i <= n; i++) { s2 += x[i]; } if(s2 == s1) cont++; } else for(int i = 0; i <= 9; i++) { x[k] = i; back(k + 1); } } int main () { cin >> n; back(0); cout << cont; return 0; } |
| TLE on #8 | Shervin | 1423. String Tale | 11 Feb 2015 09:24 | 1 |
I'm using KMP I don't know why I get TLE? #include <iostream> int main(int argc, const char * argv[]) { long long int NumofChars; long long int finAns=-1;
scanf("%lld",&NumofChars);
char lettersS[2*NumofChars]; char lettersT[NumofChars]; char letter_tmp;
for (long long int i=0;i<NumofChars;i++) { scanf(" %c",&letter_tmp); lettersT[i]=letter_tmp; }
for (long long int i=0;i<NumofChars;i++) { scanf(" %c",&letter_tmp); lettersS[i]=letter_tmp; lettersS[i+NumofChars]=letter_tmp; }
long long int prefix[NumofChars]; prefix[0]=0; prefix[1]=0;
long long int pi=0; long long int pj=1;
while(pj<NumofChars-1) { if(lettersT[pi]==lettersT[pj]) { prefix[pj+1]=prefix[pj]+1; pi++; pj++;
} else {
pi=0; if(lettersT[pi]==lettersT[pj]) { prefix[pj+1]=1; pi++; pj++;
} else { prefix[pj+1]=0; pj++;
}
} }
finAns=-1;
long long int i=0; while(i<NumofChars) {
long long int Matchcount=0; long long int j_init=0; for (long long int j=j_init;j<NumofChars;j++) { if(lettersS[i+j]==lettersT[j]) { Matchcount++; } else { if(j-prefix[j]>0) { i=i+j-prefix[j]; j_init=prefix[j];
} else { i++; }
break; } }
if(Matchcount==NumofChars) { finAns=i;
break; } } std::cout<<finAns; return 0; } |
| Don't cook steaks like that! | alextj | 1820. Ural Steaks | 11 Feb 2015 01:34 | 1 |
Whoever thought of this problem haven't fried steaks in real life. The only way to get an acceptable solution to 1820 is to cook the steaks somewhat similar to this order: Minute 1: St1A, St2A Minute 2: St1B, St3A Minute 3: St2B, St3B (where there are three steaks: St1, St2 and St3, and each having side A and side B). The problem with this is: After St2A side is cooked, it will be taken off the heat and cool down for one minute before cooking the other side, thus in the end the steak will be less cooked than stake 1 and 3. That's all sorts of wrong, you'll be ruining a good steak! :-D |
| TLE | Petru Trimbitas | 1846. GCD 2010 | 10 Feb 2015 20:23 | 2 |
TLE Petru Trimbitas 3 Dec 2011 21:33 For those who get TLE #17 try to use scanf/printf instead of cin/cout Thank you Petru, your advice helped me to pass from TLE 17 to TLE 29 :) |
| Why if n=4, the answer is 204 | plague | 1586. Threeprime Numbers | 9 Feb 2015 19:41 | 3 |
Explain me please, why if n=4, the answer is 204. I get 2513. 1031 is not a THREE-PRIME nummber. 103 is THREE-PRIME nummber, but 031 isn't, it's TWO-PRIME number Thank you for question and answers. It help to understand the task. |
| WA#5 CLOSED | dingo | 1306. Sequence Median | 9 Feb 2015 19:17 | 2 |
Here is my code: ----- [The code was here] ----- I've got the point. Thank you. Edited by author 17.07.2011 18:48 |
| RE - #14..(c++). because of map<string,int>? | OIdiot | 1837. Isenbaev's Number | 9 Feb 2015 07:13 | 2 |
/* Machine: Class4_B2 System: Windows7 SP1 32bit */ [code deleted] Edited by moderator 19.11.2019 23:15 My bad.. I thought it only contains 100 names, but 300 in fact. |