| Show all threads Hide all threads Show all messages Hide all messages |
| Help with task | Edger | | 19 Oct 2012 20:29 | 1 |
I have got problem with this task from my university algorithm course (translated from german): > John have got a party. He prepared $x$ glasses of vodka and $k*x$ > glasses of rum. > > Number of glasses is n. Each guests drink one > round of alcohol (one round is $k$ glasses of rum and $one$ of vodka) but > guest must chose glass that every full glass must have got one full > neighbor. > > Write the program which simulate John's party. The party ends when all > glasses are empty. > > In input we have got $n$ and $k$ which means number of glasses and number > of glasses of rum drunk in single turn). Simple Input : (assume that r is rum and v - vodka ). > 16 3 vvrrrvrvrrrrrrrr Simple Output : (we numbered glass 1...n) > 1 14 15 16 > 2 11 12 13 > 3 4 5 6 > 7 8 9 10 Explain : Guest 1 drink 1, 14, 15 and 16 glass. Guest 2 drink 2, 11, 12, 13 glass. etc. We write it in ascending order. Notice that we have got $\frac{n}{(k+1)}$ guests, $n$ glasses, $k$ glasses of rum in every round. And in all inputs $k+1$ divides $n$. And $n$ can be very big - about 2 000 000. And we have about 1-2s to answer the question. Find the fastest as possible algorithm to solve this problem. Thanks for every help. If you have got any questions, i will answer it. Edger. |
| Help me... | Cezar Mocan | 1149. Sinus Dances | 19 Oct 2012 17:23 | 6 |
What does the program output for n=0? |
| can anyone explain me the sample | Anupam Ghosh, Wipro Technologies | 1180. Stone Game | 18 Oct 2012 21:53 | 2 |
Hi All,
1. 1st player Take 2 stones left over is 8-2=6 2. 2nd player takes 1 stone left over is 6-1=5 3. 1st player takes either 1 (left over is 4)0r 4 stones (left over is 1) 4. Finally 2nd player takes remiang stones. Thus second player wins. Did I understand the problem statements properly? According to the output given in sample 1st player has won but how? Please could you explain. Regards Anupam Now I got it, in 3rd step player picks up 2 stones. Then it guarnatees win of 1st player. |
| why??? | Ahmet Faruk Ozkan OTTOMAN(Devlet - i Âliye)) | 1087. The Time to Take Stones | 18 Oct 2012 17:07 | 1 |
why??? Ahmet Faruk Ozkan OTTOMAN(Devlet - i Âliye)) 18 Oct 2012 17:07 4 3 1 1 3 1 4 or 1 3 4 1 3 1 4 sum of all is 17 and first player wins not second, can somebody explan? Edited by author 18.10.2012 17:08 Edited by author 18.10.2012 17:11 |
| Why it is wrong? Pascal. | Mad_Sanek | 1020. Rope | 18 Oct 2012 16:49 | 2 |
Program nitochka; var n,r,i:integer; x: array [1..100] of real; y: array [1..100] of real; s,sg:real; begin s:=0; readln(n,r); For i:=1 to n do readln(x[i],y[i]); sg:=2*pi*r; For i:=1 to n-1 do s:=s+sqrt(sqr(x[i]-x[i+1])+sqr(y[i]-y[i+1])); s:=s+sqrt(sqr(x[n]-x[1])+sqr(y[n]-y[1])); s:=s+sg; writeln(s:1:2); end. The example calculates correct Потому что ты не берешь из файла и не выводиш в файл (assign(.....)) |
| can you write hear some examples? | Ahmet Faruk Ozkan OTTOMAN(Devlet - i Âliye)) | 1180. Stone Game | 18 Oct 2012 14:11 | 3 |
can you write hear some examples? for 12 the answer is 2 is it true
ı understood Edited by author 18.10.2012 14:14 Edited by author 18.10.2012 14:14 |
| if Wa on test#2,try this case | ykwd | 1057. Amount of Degrees | 18 Oct 2012 12:41 | 1 |
|
| Hint for this problem ! | Phan Hoài Nam - Đại học Ngoại ngữ Tin Học TP.HCM | 1003. Parity | 17 Oct 2012 21:00 | 2 |
There are only one trick in this problem, it's the position of the first and last digit, the first position can be smaller 0 and the last position can be larger than the length, so you can consider the following segment of code: if(first<0 || last > 0) { //stop the code and print output } Chào A!E mới hoc lập trình C.code mãi bài 1106. Two Teams mà vẫn con sai mấy trường họp...:(( a gui code cho e bài dấy dc ko thanks A! Email:phuongvut8@gmail.com Edited by author 17.10.2012 21:01 Edited by author 17.10.2012 21:01 |
| WA#2 TEST. WHATS WRONG??????? | Master of C++ | 1370. Magician | 17 Oct 2012 19:17 | 2 |
#include <iostream.h> int main() { int N,M,i,t; cin>>N>>M; int *mas=new int [N]; int *mas2=new int [N]; for(i=1;i<=N;i++) cin>>mas[i]; for(i=1;i<=N;i++) { t=i+M; if(t>N) { t-=N; } mas2[t]=mas[i]; } if(N>10) { for(i=3;i<=N;i++) cout<<mas2[i]; } else { for(i=1;i<=N;i++) cout<<mas2[i]; } return 0; } If you wnat to use cin and cout you must write using namespace std; |
| Please give answers to the tests: | Yermak | 1908. Brute-force Search | 17 Oct 2012 17:34 | 3 |
1 ab 1 abcd 2 a b 2 ab bc 4 aa ab ba bb 6 a ba bb ca cb cc Edited by author 15.10.2012 02:26 Edited by author 15.10.2012 02:40 |
| Problem 1206 "Sum of digits". New tests have been added (+) | Vladimir Yakovlev (USU) | 1206. Sum of Digits of the Sum of Numbers | 17 Oct 2012 10:41 | 4 |
New tests were added to the problem. All possible inputs are checked now :) Problem statement was updated: limitation "0 < K <= 50" was replaced by "2 <= K <= 50". There wasn't a case K=1 in the tests. AC submissions were rejudged, 44 of them lost AC. I think who write true program with long arithmetics hasn,t lost ACC!!! Thanks. I know why I wa 1 |
| Easy to solve HINT | AzizIO | 1712. Cipher Grille | 17 Oct 2012 02:36 | 1 |
Code in C#!!! first of ALL just print and reverse print .... 3 times static string [,] reverse(string[,] arr) { string[,] tmp = new string [4,4];
for (int i = 0; i < 4; i++) { for (int j = 0; j < 4 ; j++) { tmp[i,j] = arr[4-j-1,i]; } } return tmp; } in this case i wrote code for 4x4 array!!! you can change your code to tmp[i,j] = arr[3-j,i] if u want reverse nxn array change all 4 to n GooD Luck! sorry for my english!! Edited by author 17.10.2012 02:39 |
| Чем бы заменить решето? | Alexsander827 | 1356. Something Easier | 17 Oct 2012 01:04 | 1 |
|
| Using STL algorithm | SANIA (LNU) | 1370. Magician | 16 Oct 2012 23:57 | 2 |
Look how to use STL algorithm rotate(). It's very easy: rotate(arr, arr + k, arr + N); Thanks !!! I think it will be helpful in the future. |
| big,big i mean huge problem(or misunderstanding) | AXIS ZULU | 1180. Stone Game | 16 Oct 2012 23:49 | 3 |
ok... if the player 2 wins, then stop showing the second line? pls give help yes. input : 3 output: 2 good luck! |
| i cannot understand the problem !!! | IRAKLI | 1228. Array | 16 Oct 2012 23:38 | 4 |
P( i<1> , i<2> , i<3> , ... , i<n-1> , i<n> ) determines at which position is the X[ i<1> , i<2> , i<3> , ... , i<n-1> , i<n> ] element in ( lets say ) RAM . And the Function P is absolutely correct. You should determine the dimensions k<1> , k<2> , k<3> , ... , k<n-1> , k<n> of the X for the given D elements. I don't know whether I could explain it, if not I'm really sorry ! I can't do much. :( Edited by author 16.10.2012 23:40 Edited by author 16.10.2012 23:39 |
| C# How I can read data?? | Alexandr | 1196. History Exam | 16 Oct 2012 22:01 | 2 |
teach=Int32.Parse(Console.ReadLine()); String[] arrTeach = new String[teach] for (Int32 i = 0; i < teach; i++) arrTeach[i] = Console.ReadLine(); //It no worked correct on timus compiler! Why? Console.ReadLine() return string You should just parse to int for (long i = 0; i < M; i++) { arrS[i] = long.Parse(Console.ReadLine()); } in your case arrTeach[i] = int.Parse(Console.ReadLine()); good luck with C# :) Sorry for my English |
| WA 4 | Глащенко Никита | 1189. Pairs of Integers | 16 Oct 2012 18:51 | 3 |
WA 4 Глащенко Никита 7 Aug 2009 13:26 Can anybody help me with WA 4? My program passes all tests given in discuss... Re: WA 4 Глащенко Никита 7 Aug 2009 19:35 Silly mistake, as usually. Incorrect number of zeros. Re: WA 4 IgorKoval(from Pskov) 16 Oct 2012 18:51 Try this test: 100 Answer: 3 91 + 9 = 100 95 + 5 = 100 100 + 00 = 100 Somebody can get "50 + 50 = 100". It's wrong by problem. =). Edited by author 16.10.2012 18:52 |
| Why CE ?? | Александр | 1581. Teamwork | 16 Oct 2012 16:33 | 1 |
#include<stdio.h> int main() { int N; scanf("%d", &N); int start; scanf("%d", &start); int sum = 1; for(int i = 1; i < N; i++) { int a; scanf("%d", &a); if(a == start) { sum++; } else { printf("%d %d ", sum, start); start = a; sum = 1; } } printf("%d %d ", sum, start); return 0; } |
| What is test 2 and what is wrong with my code? C programming language | creaky | 1068. Sum | 16 Oct 2012 16:06 | 3 |
#include<stdio.h> main() { int a, sum=0; scanf("%d",&a); if(a<0&&a>=-10000) { int i; for(i=a;i<=1;i++) { sum=sum +i;
} printf("%d",sum); } else if( a>=0&&a<=10000) { int i; for(i=1;i<=a;i++) { sum=sum +i; } printf("%d",sum);
} }
when a = 0, the answer is 1, not 0 Edited by author 12.10.2012 23:50 I have executed the program and when I input 0 the result is also 0. But still they are not accepted |