Общий форумmy english is poor so this is the program using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; namespace ACM1001test { class Program { static void Main(string[] args) { string[] arr = (Console.ReadLine()).Split(' '); Stack sck = new Stack(); for (int i = 0; i < arr.Length;i++ ) { sck.Push(arr[i]); } foreach (string str in sck) { int a=Convert.ToInt32(sck.Pop()); Console.WriteLine("{0}/n",Math.Round(Math.Sqrt(a), 4)); } } } } 1. string[] arr = (Console.ReadLine()).Split(' '); Number of lines may be more then one, use cycle 2. the number of spaces between the numbers of more than one, use Console.ReadLine().Split(new char[] {' ', '\t'}, StringSplitOptions.RemoveEmptyEntries) 3. Int32<10^18; thanks Alksar so i made some changes but some problems is still here .this is the new program class Program { static void Main(string[] args) { string[] arr = Console.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); Stack sck = new Stack(); for (int i = 0; i < arr.Length;i++ ) { sck.Push(arr[i]); } foreach (string str in sck) { ulong a=Convert.ToUInt64(sck.Pop()); Console.WriteLine("{0}/n",Math.Round(Math.Sqrt(a), 4)); } } } when i input the "16 4" the computer output the "20" so awkwardful..... I have changed your program just a little, it works nice namespace ACM1001test { class Program { static void Main(string[] args) { string[] arr = Console.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); Stack sck = new Stack(); for (int i = 0; i < arr.Length; i++) { sck.Push(arr[i]); } while (sck.Count>0) { ulong a = Convert.ToUInt64(sck.Pop()); Console.WriteLine(Math.Round(Math.Sqrt(a), 4)); } Console.ReadKey(); } } } thanks but when i input "16 4"the computer also output "20" when i submit the program i get the Crash and i used the others Program which use C# have got the AC,they also output "20". it is not should put out"2 4"? or i am not understand the meaning... That is my code on c++ #include <iostream> #include <stdio.h> using namespace std; int main() { int k, n; scanf ("%d %d", &k, &n); int *mas = new int [n]; for (int i = 0; i < n; i++) { scanf("%d",&mas[i]); } int sum = 0; for (int i = 0 ; i < n ; i++) { sum+=mas[i] - k; } delete[]mas; if (sum<0) { sum = 0; cout<<sum; return 0; } cout<<sum; return 0; } Edited by author 01.02.2013 09:18 Hello all, I've been studying this topic lately, and I came out with a question which answer I have not been able to find anywhere. I know very well the history about Edmonds' Blossom algorithm, however, it is well known that a given matching is the maximum one if no more augmenting paths can be found on the graph. So, my question is the following one: I implemented a simple DFS algorithm that tries to find an augmenting path, and if found, it makes the flip we all know and adds/removes the flipped edges to the matching. In my DFS I only mark nodes that are reached in even levels (i.e. nodes found after following a matched edge, plus the first unmatched node) as visited, furthermore I also care about the nodes in the active path so as to avoid stepping in the same node and generating cycles. So, why this does not work? of course the reason is because there are augmenting paths my algorithm cannot find, but why? All of this converges to a simple question: why in Edmonds' algorithm is it necessary to shrink blossoms? I've read many papers where it is explained how to shrink blossoms and why an augmenting path in the reduced graph is still valid in the expanded one, but they never explain why this is actually necessary! Thanks for your help. /* * Created by SharpDevelop. * User: Жамшидбек * Date: 31.01.2013 * Time: 20:02 * * To change this template use Tools | Options | Coding | Edit Standard Headers. */ using namespace System; int main(array<System::String ^> ^args) { Console::WriteLine(L"Hello World"); return 0; } using System;namespace jama{class Program{static void Main(string[] args){ushort n = ushort.Parse(Console .ReadLine());string[] a = new string[n];for (ushort i = 0; i <= n - 1; i++){a[i] = Console.ReadLine();}string b = Console.ReadLine();foreach (string d in a){if (d.Substring(1,1) == b)Console.WriteLine(d);}Console.ReadLine();}}} Incorrect: "которую могут маги ещё могут пережить" Correct: "которую маги ещё могут пережить" Nikolay Ulyanov [EPFL Clockworks] Scala support [1] 30 янв 2013 04:53 Hello, is it possible to add support for this beautiful language? Thanks. and I hope Python is the next language to add. Of course, more languages offer more choices. Can someone give me a hint for this task? Thanks! Project everything onto sphere R=1, now you have 2D problem because Z can be evaluated from X and Y. Projections' countours will be circles. Then find limiting Y - i.e. Y values for which some particular projection has only one point on that R=1 sphere. Then find all Y values for which two projections start/stop intersecting. For every pair of projections there will be at most 2 such Y values, so we will have at most O(N^2) control Y points. Now, for each particular Y value each projection will constitute some [X1;X2] interval and it becomes a classic point-in-max-number-of-segments problem (O(N*log(N)). So, the overall complexity is O(N^3*log(N)). And a lot of math about square equations. Edited by author 05.08.2008 19:02 Edited by author 05.08.2008 19:57 Edited by author 05.08.2008 20:00 Edited by author 05.08.2008 19:49 overall complexity is O(N^3) In the fourth sentence they should insert a comma after the third word. Edited by author 30.01.2013 00:12 My first program gives right answers for all the extremal tests, that I think out for my AC program, but it can not pass this test with diagnosis "Crash (access violation)". Why? What checks this test? Edited by author 30.01.2013 01:45 Guys, i run program and it works. Why does it crash? Could you point me to the problem in my code? public static void main(String[] args) throws IOException { int sum=0; Scanner s = new Scanner (System.in); int a = s.nextInt (); BufferedReader br = new BufferedReader (new InputStreamReader (System.in)); String s1 = br.readLine (); for (int i = 0; i<a-2; i++) { if (s1.charAt (i)==s1.charAt (i+1) && s1.charAt (i) == s1.charAt (i+2)) { String s2 = Character.toString (s1.charAt (i)); sum = Integer.parseInt (s2); System.out.print (sum*3 + " "); } } for (int i = 0; i<a-2; i++) { if (s1.charAt (i)==s1.charAt (i+1) && s1.charAt (i) == s1.charAt (i+2)) { System.out.print (s1.indexOf(s1.charAt (i))+2); } Is input always made in given range or your tests may input not allowed numbers (like -1) and i must write code to handle this input error? Must this numbers 1 4 4 4 1 1 be randomly generated or what? Must numbers other than 4 (in this case) be always 1? Or be the same? Edited by author 25.01.2013 20:56 Edited by author 25.01.2013 20:56 The input data is in the given range. As you can see from the problem statement, instead of the 1 and 4 there could be any number in range [1, 1000000]. Guys, I get 'Crash' message but cant undrestand why. I run programm and it does what it has to do. Could u please look look at the code ant point me to the problem? This is JAVA public static void main(String[] args) throws IOException { int sum=0; Scanner s = new Scanner (System.in); int a = s.nextInt ();
BufferedReader br = new BufferedReader (new InputStreamReader (System.in)); String s1 = br.readLine ();
for (int i = 0; i<a-2; i++) { if (s1.charAt (i)==s1.charAt (i+1) && s1.charAt (i) == s1.charAt (i+2)) { String s2 = Character.toString (s1.charAt (i)); sum = Integer.parseInt (s2); System.out.print (sum*3 + " ");
} }
for (int i = 0; i<a-2; i++) { if (s1.charAt (i)==s1.charAt (i+1) && s1.charAt (i) == s1.charAt (i+2)) {
System.out.print (s1.indexOf(s1.charAt (i))+2);
}
What is test 2? Try this 10 5 3 Answer: 4. My program is right for this test. first 7 tests are all strings of length 6. so if you wa 8, your program may not handle string of length > 6. using System; static class Module1 { public static void Main() { short n = short.Parse(Console.ReadLine()); string[] a = Console.ReadLine().Split(); int i = 0; int temp = 0; int max = 0; int numb = 0; while (i + 3 <= n) { temp = int.Parse(a[i]) + int.Parse(a[i + 1]) + int.Parse(a[i + 2]); if (temp > max) { max = temp; numb = i + 2; } i += 1; } Console.WriteLine(max + " " + numb); } } Does the MSVC++ compiler used on the judging machine come with the relevant headers (emmintrinsics.h etc) for using SSE, SSE2, etc? If so, which instruction sets are supported? The result isn't greater than 1 000 000 000. So everytime you make "element = something" you should do "element = min(something, 1 000 000 000)" , min(a, b) returns a if a < b of b if a > b. Try getting next day flight if no flight is available after delay by adding 24*60 to flight timings. |
|