Show all threads Hide all threads Show all messages Hide all messages |
How to reduce time?? | Varun Kumar(Fundu) | 1264. Workdays | 11 Jan 2022 10:41 | 6 |
Soln accepted but time is .156 how to reduce to atleast 0.078 and also how to reduce memory usuage? import java.util.*; import java.io.*; public class prob1264{ public static void main(String args[]) { Scanner sc=new Scanner(System.in); PrintWriter out=new PrintWriter(System.out); int n=sc.nextInt(); int m=sc.nextInt(); int result=n*(m+1); out.print(result); out.close(); } } Just use such construction, I have time 0.093: StreamTokenizer in = new StreamTokenizer(new BufferedReader( new InputStreamReader(System.in))); PrintWriter out = new PrintWriter( new OutputStreamWriter(System.out), true);
in.nextToken(); int n = (int)in.nval; in.nextToken(); int m = (int)in.nval;
out.println(n * (m + 1)); I know the problem! You're using Java. |
It is a very easy problem!!!!!!!! | XiangGuangTe | 1264. Workdays | 5 Nov 2019 09:06 | 9 |
yeah, it's mega simple problem... Yeah, it's simple but why my answer was wrong? anyone can help? Give me your code and I will help you Edited by author 31.01.2015 13:34 Edited by author 31.01.2015 13:34 why "N*(M+1)" i can't understand pls help "For each integer from 0 to M the function would calculate how many times this number appears in the N-element array..." Let's say N=2, so you have two-element array. Let's M=4, so you have to check whether there is any 0,1,2,3 or 4 (since from 0 to M) in each array... So total lines = 2*(4+1) Hope, it helped. how could 3 or 4 in the n? cause n = 2 so 3 or 4 are not in the array....for this reason why we don't use if else statement to see whether m is bigger than n or not...but we calculate it straightly?...can you please describe? because, a box is given as a clue ..... and you have to solve the problem according to that.. i guess :/ |
задача оч короткая | mathew | 1264. Workdays | 10 Dec 2018 19:57 | 1 |
Edited by author 21.01.2019 19:40 |
здавствуйте! | dainil | 1264. Workdays | 11 Nov 2018 00:24 | 1 |
помогите понять условие, пожалуйста, буду благодарен |
I have two solutions and neither is correct. Why? | pimiento | 1264. Workdays | 1 Jan 2018 23:14 | 3 |
In Python 3.0: N = int(input()) M = int(input()) result = N*(M+1) print(result) #It produces runtime error In C: #include <stdio.h> int main(void) { short int n, k; scanf("%4hd%4hd", &n, &k); printf("%hd\n", n * (k+1)); return 0; } # It produces wrong answer for test N7 SHORT_MAX, probably, is 32767. Replace short with long or long long. Edited by author 26.11.2013 10:16 scanf("%4hd%4hd", &n, &k); /// you dont need this scanf("%i %i", &n, &k); // like this |
How to make this on c++ ? | Nickolas | 1264. Workdays | 8 Jun 2015 22:45 | 2 |
we have N element array. And we have (M+1) integers, as numaration starts form 0 to M. so, (M+1) integers will be checked in every element of the array. as, there's N elements in the array, so, final result is N*(M+1). :) ------------------------------------ #include <iostream> using namespace std; int main() { int n, m; cin >> n >> m; cout << n * (m + 1) << '\n'; return 0; } --------------------------------------- |
TLE | Ehsan Raeyatpisheh | 1264. Workdays | 8 Jun 2015 22:42 | 2 |
TLE Ehsan Raeyatpisheh 7 Jun 2015 11:32 I'm getting time limit exceeded using this algorithm, any optimization suggestions? This problem is taking almost a week 8-| total = 0 for i from 1 to N for j from 0 to M total++ print total Edited by author 07.06.2015 11:34 Re: TLE Md. Shahedul Islam (Shahed) 8 Jun 2015 22:42 why using loop, just simply, we have N element array. And we have (M+1) integers, as numaration starts form 0 to M. so, (M+1) integers will be checked in every element of the array. as, there's N elements in the array, so, final result is N*(M+1). :) ------------------------------------ #include <iostream> using namespace std; int main() { int n, m;
cin >> n >> m; cout << n * (m + 1) << '\n'; return 0; } --------------------------------------- Edited by author 08.06.2015 22:43 |
Why we get all waiting stauts | Peca | 1264. Workdays | 29 May 2015 19:34 | 1 |
When I submit this problem I get waiting status and I am not the only one. |
Why ? Crash | Crushedsheet | 1264. Workdays | 25 Jan 2013 23:19 | 2 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication3 { class Program { static void Main(string[] args) { string[] nums = Console.ReadLine().Split(' '); long n = int.Parse(nums[0]); long m = int.Parse(nums[1]); if (0 <= n && n <= 40000) { if (0 <= m && m <= 40000) { Console.WriteLine(n * (m + 1)); Console.ReadKey(); } } } } } I suggest you to remove "if" statements, because there is no alternative output provided. Also, try to remove Console.ReadKey(); line before posting your code. |
You've gotta be kidding me | Dinu Cristian M | 1264. Workdays | 28 Nov 2012 16:00 | 3 |
Right... I guess this problem was put in here for comic relief. :) For crying out loud, the author didn't even bother to increase the limits so as to make this a 'bignum' problem... :P This is "Осеннее первенство школьников 2003". Now you understand why it is so easy? And yet, this problem has a higher site difficulty than Ural Steaks, which is a much more sophisticated problem than this one. The difficulty of a problem is not necessarily related to how much code it takes to solve it, the point of problem solving is to map scenarios to programs that solve them. It is the proper understanding of the problem where a lot of the difficulty (and most of the importance!) lies. |
omg,, mega simple.. | Zhihua Lai | 1264. Workdays | 26 Nov 2012 21:35 | 2 |
this kind of problems are easy,, i guess they exist to build up your confidence. xD |
How to get 0.015 with 112 memory? | Victor | 1264. Workdays | 14 Nov 2012 23:37 | 2 |
|
Complexity of the task | Meir | 1264. Workdays | 23 Aug 2011 11:46 | 2 |
I think that complexity 68 is too big for this task and should be significantly reduced. It's counted with formula, so if more authors solve it - it'l become easier. |
dp | Tiberiu Florea | 1264. Workdays | 8 Aug 2011 22:29 | 6 |
dp Tiberiu Florea 11 Apr 2004 04:21 is this dynamic programming ? :) or maybe we could try a nice branch and bound ! ;) Re: dp 107th 23 Mar 2007 16:18 Re: dp Rustam 26 Apr 2008 17:25 it's not a dp! this problem is much simpler than you think! answer is n*(m+1). who wants to get explanation, email me rganeyev at gmail.com Re: dp Armen Tsirunyan 4 Dec 2008 02:00 Oh Really???!!! Isn't it DP?! WOW! BUT HOW?!!! Oh please please DO tell me, how on earth can this extremely sophisticated problem be solved without DP! I read your formula, but I can't understand it. Oh please help. :)))) Re: dp Nikita Artyushov (SPb SU, mat-meh) 27 Oct 2009 02:11 After many WA I finally got AC. That was one tough problem :D |
How to put in 0.001 second? | 15Sanek15 | 1264. Workdays | 26 Jun 2009 01:44 | 2 |
If you about getting 0.015, now you cannot get less because of system aspects, as I know. If in something way it's about problem, it's easy :) |
O(1) algorithm :3 | Nikita | 1264. Workdays | 5 Jun 2009 00:47 | 2 |
|
Just for rookies : readln(n,m); writeln(n*(m+1)); | Lutsenko | 1264. Workdays | 24 Mar 2009 12:42 | 2 |
|
HaHa It Done | IceWorld | 1264. Workdays | 23 Apr 2005 07:48 | 1 |
var n,m:longint; begin readln(n,m); writeln(n*(m+1)); end. |