Общий форумWhat is different with case #15. My program runs good for 14 tests. import java.io.*; import java.util.Scanner; public class string { public static void main(String args[]) throws IOException { Scanner sc = new Scanner(System.in); BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in)); String each; int m=0,l=0,e=0; int num = sc.nextInt(); for(int i=0;i<num;i++) { each = bufferedreader.readLine(); if(each.charAt(0)=='M') { m++; } else if(each.charAt(0)=='L') { l++; } else if(each.charAt(0)=='E') { e++; } } if((m>=l) && (m>=e)) System.out.println("Macaroni Penguin"); if((l>=m) && (l>=e)) System.out.println("Little Penguin"); if((e>=m) && (e>=l)) System.out.println("Emperor Penguin");
} Same question, maybe related with BufferedReader. Several times faced with this problem, any idea? Are there exactly two plates to be put on the tray or can there be more/less than two? Can someone clarify this for me? Thanks! I'm using simple DFS from every point and got TLE on 5th test. Wich algo should I use to solve it faster? Yeah, i also have this problem :) Got AC, 0.078 :) MOPDOBOPOT, it it a so easy problem, just generate all words that you can get from table, and using this list just check all words. Edited by author 04.09.2012 21:28 what is in 13 test? Maybe something like that: n=5 k=3 The correct answer is 4 Exactly n == 7 && k == 3. True answer is 5! Thanks for a great test!!! Exactly n == 7 && k == 3. True answer is 5! WRONG true answer is 6!!!! I. 3 steak = 2 sec; II. 3 steak = 2 sec; III. 1 steak = 2 sec; 2+2+2=6. Edited by author 05.07.2012 20:16 Edited by author 05.07.2012 20:16 then 3 2 should be 4 . how they are 3 U r wrong: Sec status( 0-raw, 1-one side raw, 2-ready ) 1. 111 000 0 2. 222 000 0 3. 222 111 0 4. 222 221 1 5. 222 222 2 I've just found this mistake of mine :) U r wrong: Sec status( 0-raw, 1-one side raw, 2-ready ) 1. 111 000 0 2. 222 000 0 3. 222 111 0 4. 222 221 1 5. 222 222 2 I've just found this mistake of mine :) I don't know how to solve this problem with DP, because here is just a one cycle without any cool thinking) Where is a DP here?) It's just a easy problem. Edited by author 04.09.2012 14:40 Edited by author 04.09.2012 14:40 what is test #5? why did I have wa var k,n,s,j,max:integer; a:array [0..100000] of integer; b:array [1..10] of integer; begin a[1]:=1; a[0]:=0; for k:=2 to 10000 do begin if k mod 2 =0 then a[k]:=a[k div 2] else a[k]:=a[k div 2]+a[(k div 2)+1]; end; k:=0; while not eof do begin k:=k+1; readln(b[k]); end; n:=k-1; for k:=1 to n do begin max:=0; s:=b[k]; for j:=1 to s do begin if a[j]>max then max:=a[j]; end; writeln(max); end; end. Same problem here. It gives me crash on test 5. Maybe it's something to do with the case when the input consists of only one line - 0 as it's not specified what the program should do then. Yep, same here.... crash using java on test 5. GOT AC... error was when input was repeated e.g: 10000 10000 0 Answer: 521 521 My program was crashing because of using a set. GL Edited by author 03.10.2010 06:24 where you find test cases? Guys, apparently this problem is not solvable in C#. Even it is written in FAQ: “It’s not recommended to use Java and C# for solving following problems: 1220, 1275, 1306.” Just creating half of the required array length with int gives Memory Limit Error Like using System; public class Program { private static void Main() { int[] nn=new int[125000]; } } This code gives Memory Limit Error. But some people solved in Java. To whom who solved in Java, what was the array length in your case? Does it give Memory Limit Error in Java creating 125000 elements in int type ? So should I learn C++? Is it worth it? Thanks for suggestions. Edited by author 02.09.2012 16:14 To whom who solved in Java or C#, Could you please send me the algorithm or solution to fakel2005@gmail.com Thanks a lot I’m sorry I’m obsessed with this problem using System; public class Program { private static void Main() {
} } Why this code gives me “Memory Limit Exceeded?” I’m not doing anything here. How is it even possible then writing something in it and expecting not to get MLE? I have a question, if you submit those codes who solved in C# NOW, will it give AC NOW as before? What I mean is maybe C# compiler which is being used now consumes too much memory? Thanks, It works in my computer 0k... #include<iostream> #include<string.h> #include<cstdio> #include<vector> #include<cmath> using namespace std; int main(){ unsigned long long aux; vector<unsigned long long>v1; while(cin >> aux)v1.push_back(aux); int i=v1.size()-1; while(i>=0){ printf("%.4f\n",sqrt(v1[i])); i--; } } cb37c1a6-2f8c-4b8d-9b35-bb945448c8b1 cb37c1a6-2f8c-4b8d-9b35-bb945448c8b1(14) : error C2668: 'sqrt' : ambiguous call to overloaded function S:\checker\compile\vc10\include\math.h(589): could be 'long double sqrt(long double)' S:\checker\compile\vc10\include\math.h(541): or 'float sqrt(float)' S:\checker\compile\vc10\include\math.h(127): or 'double sqrt(double)' while trying to match the argument list '(unsigned __int64)' Just make vector of doubles. Everything will be OK. Error because function sqrt() gets double or long double or float parameter. #include <iostream> #include <stdio.h> int main() { long n,k,t; scanf("%ld%ld",&n,&k); t=2*(n/k)+(n%k!=0)+((n%k>k/2.0)||(n<k)); printf("%ld\n",t); return 0; } Edited by author 05.05.2012 14:45 Edited by author 05.05.2012 14:45 but sometimes 0.031. Don't know why.. Edited by author 05.05.2012 15:05 result is n/k+1 + (n-1+n%k)/k to avoid WA8 check if k is greater than n. Can you explain it for me? I can't understand this formular.(sorry for my English) what's wrong in my code? Here is my code: #include <stdio.h> main() { int x[100][100],a,i,j; scanf("%d",&a); for( i = 0 ; i < a ; i++ ) for( j = 0 ; j < a ; j++ ) scanf("%d",&x[i][j]); for( i = 0 ; i < a ; i++ ) for( j = 0 ; j <= i ; j++ ) printf("%d ",x[i-j][j]); for( i = a ; i < 2 * a - 1 ; i++ ) for( j = a - 1 ; j >= i - 3 ; j-- ) printf("%d ",x[j][i-j]); return 0; } Edited by author 31.08.2012 20:24 After reading the background, I thought it would always be q[i]<=p[i]. But it seems not so, and normal dp is ok... #include <stdio.h> #include <math.h> main() { int a,x[65535],i,t,delta; float x1; scanf("%d",&a); for( i = 0 ; i < a ; i++ ) scanf("%d",&x[i]); for( i = 0 ; i < a ; i++ ) { t = (x[i] - 1) * 2; delta = 1 + 4 * t; x1 = sqrt(delta); printf("%d ",fmod(x1,1.0) == 0); } return 0; } If you have problems with size of program stack just read FAQ and use special directives :) In pascal it is {$M 16777216} then the problem is clear what's wrong? #include <stdio.h> #include <conio.h> main() { int a,len=0,t=1; char b[20]; scanf("%d%s",&a,b); len = strlen(b); for( ; a > 1 ; a -= len ) t *= a; printf("%d",t); return 0; }
int result = 1; for (int i = n; i > 0; i -= k) result *= i; printf("%d\n", result); In testing my code .. it gets stuck in toggling between 41325 and 24315...and ends in infinite loop. Can anyone help me with what I might be doing wrong ? I think I got it .. what was going wrong. I am failing test#1 .. can anyone hint me what is it? please anyone help me if accepted . it gives me wrong answer on test 1 and as i suppose in test 1 k=0 and i don't know what write :) thanks... int result = 1;
for (int i = n; i > 0; i -= k) result *= i; |
|