<\/span><\/h2>\n\n\n\nA progress bar is an element of graphical interface that displays the progress of a process for this very moment before it is completed. Let’s take a look at the following form of such a bar.<\/p>\n\n\n\n
A bar is represented as n<\/em> squares, located in line. To add clarity, let’s number them with positive integers from 1 to n<\/em> from the left to the right. Each square has saturation (a<\/em>i<\/em><\/sub> for the i<\/em>-th square), which is measured by an integer from 0 to k<\/em>. When the bar for some i<\/em> (1\u2009\u2264\u2009i<\/em>\u2009\u2264\u2009n<\/em>) is displayed, squares 1,\u20092,\u2009… ,\u2009i<\/em>\u2009-\u20091 has the saturation k<\/em>, squares i<\/em>\u2009+\u20091,\u2009i<\/em>\u2009+\u20092,\u2009… ,\u2009n<\/em> has the saturation 0, and the saturation of the square i<\/em> can have any value from 0 to k<\/em>.<\/p>\n\n\n\nSo some first squares of the progress bar always have the saturation k<\/em>. Some last squares always have the saturation 0. And there is no more than one square that has the saturation different from 0 and k<\/em>.<\/p>\n\n\n\nThe degree of the process’s completion is measured in percents. Let the process be t<\/em>% completed. Then the following inequation is fulfilled:<\/p>\n\n\n\nAn example of such a bar can be seen on the picture.<\/p>\n\n\n\n
For the given n<\/em>, k<\/em>, t<\/em> determine the measures of saturation for all the squares a<\/em>i<\/em><\/sub> of the progress bar.<\/p>\n\n\n\n<\/div>\n\n\n\n
Input<\/strong><\/p>\n\n\n\nWe are given 3 space-separated integers\u00a0n<\/em>,\u00a0k<\/em>,\u00a0t<\/em>\u00a0(1\u2009\u2264\u2009n<\/em>,\u2009k<\/em>\u2009\u2264\u2009100,\u00a00\u2009\u2264\u2009t<\/em>\u2009\u2264\u2009100).<\/p>\n\n\n\nOutput<\/strong><\/p>\n\n\n\nPrint\u00a0n<\/em>\u00a0numbers. The\u00a0i<\/em>-th of them should be equal to\u00a0a<\/em>i<\/em><\/sub>.<\/p>\n\n\n\n<\/div>\n\n\n\n
Examples<\/strong><\/p>\n\n\n\nInput<\/td> | 10 10 54<\/td><\/tr> |
Output<\/td> | 10 10 10 10 10 4 0 0 0 0<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<\/div>\n\n\n\n Input<\/td> | 11 13 37<\/td><\/tr> | Output<\/td> | 13 13 13 13 0 0 0 0 0 0 0<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<\/div>\n\n\n\n
\n\n\n\n <\/span>Solution<\/strong><\/span><\/h2>\n\n\n\n<\/div>\n\n\n\n <\/span>C# Solution<\/strong><\/span><\/h3>\n\n\n\nSolution1<\/strong><\/p>\n\n\n\nstring[] first = Console.ReadLine().Split(' '); \/\/split by space\nint n = int.Parse(first[0]);\nint k = int.Parse(first[1]);\nint t = int.Parse(first[2]);\n\nint res = n*k*t\/100;\nint full = res\/k;\nint left = res%k;\n\nint[]resArr = new int[n];\n\nfor(int i=0; i<n; i++){\n resArr[i] = i<full ? k : (i==full ? left : 0);\n}\n\nConsole.WriteLine(String.Join(" ", resArr));<\/code><\/pre><\/div>\n\n\n\nThis C# program generates a progress bar with n squares, each having saturation values according to specific rules. <\/p>\n\n\n\n The first full squares have saturation k, the next square has a partial saturation (left), and the remaining squares have saturation 0. The resulting saturation values are then printed to the console.<\/p>\n\n\n\n <\/div>\n\n\n\n <\/span>Java Solution<\/strong><\/span><\/h3>\n\n\n\nSolution1<\/strong><\/p>\n\n\n\nimport java.util.Scanner;\nimport java.util.Arrays;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n String[] first = scanner.nextLine().split(" ");\n \n int n = Integer.parseInt(first[0]);\n int k = Integer.parseInt(first[1]);\n int t = Integer.parseInt(first[2]); \n \n int res = n*k*t\/100;\n int full = res\/k;\n int left = res%k;\n \n int[]resArr = new int[n];\n\n for(int i=0; i<n; i++){\n resArr[i] = i<full ? k : (i==full ? left : 0);\n }\n System.out.println(String.join(" ", Arrays.stream(resArr).mapToObj(String::valueOf).toArray(String[]::new)));\n }\n}<\/code><\/pre><\/div>\n\n\n\n<\/div>\n\n\n\n
|
|