Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
AC in 5 rows | andreyDagger | 1053. Пиноккио | 8 ноя 2021 21:00 | 1 |
5 rows of code to solve this |
Can anyone translate the statement? | PrankMaN | 1053. Пиноккио | 25 авг 2019 00:22 | 2 |
My Endlish is not that good, could anyone translate it into Russian, pls? Так с гугл-переводчиком понятно |
Actually it just describes Euclid algorithm in a tedious way. | some_programming_novice | 1053. Пиноккио | 11 ноя 2018 10:21 | 1 |
|
To admins | SigmaPhiZeta | 1053. Пиноккио | 10 ноя 2015 21:18 | 2 |
заходит решение берем пары соседних чисел и выводим минимум из их нодов( #include <iostream> #include <vector> using namespace std; int gcd(int a, int b) { if(a == b) return a; while( a != 0 && b !=0) if(a > b) a%=b; else b%=a; return a+b; } int main() { int N; cin >> N; int array[1000]; for(int i = 0; i < N; i++) cin >> array[i]; if(N == 1) cout << array[0]; else{ vector <int> mins; for(int i = 0; i < N-1; i++) mins.push_back(gcd(array[i], array[i+1])); int min = mins[0]; for(int i = 0 ;i < mins.size(); i++) if(min > mins[i]) min = mins[i]; cout << min; } return 0; } это вроде не камильфо! |
Be careful to the range of N and L(i),it maybe have IMPOSSIBLE! | xiefen | 1053. Пиноккио | 27 авг 2011 13:06 | 3 |
I haven't used word "impossible" at all in my AC program :) It's impossible to get "impossible" =))) |
No matter how to choose blanks | Fokysnik | 1053. Пиноккио | 4 окт 2010 16:50 | 2 |
Confusing question: HOW ARE THE BLANKS CHOSEN? Let's see example 2 3 4 - initial blanks I choose blanks 2 and 4 - they are different so I cut off piece of length 2 from the long blank (4). After that we have blanks: 2 3 2 - two blanks coincide so one is eliminated: 2 3 they are different so we cut of blank with length 3. We have: 2 1. Cut again we have 1 1. Eliminate one blank and we get a result - 1. You may try other ways to choose blank - but you will get same answer. So, NO MATTER HOW TO CHOOSE 2 blanks. Moral: What is not said does not matters ;) By the way algorithm is very very easy... try to think Captain Obvious Edited by author 04.10.2010 16:51 |
test 5 | ghostfreak | 1053. Пиноккио | 9 май 2010 19:59 | 4 |
test 5 ghostfreak 14 июл 2009 20:48 does anybody knows what is this fucking test 5? if you know write the answer please:) sorry i've mistaked i've written knows instead of know Re: SuperLight 14 июл 2009 22:45 |
why time limit??? | ghostfreak | 1053. Пиноккио | 26 апр 2010 20:48 | 1 |
i've got tl on tets 7 cannot you say why? i just calculate gcd of all numbers Edited by author 26.04.2010 21:02 Edited by author 26.04.2010 21:03 |
what's wrong with that code :( | Bartosz | 1053. Пиноккио | 8 янв 2010 15:19 | 2 |
#include <cstdlib> #include <iostream> //----------Funkcje---------------------------- long long nwd(long long a, long long b) { if (b>=1) nwd(b, a%b); if (b=0) return a; } using namespace std; //---------------Program------------------------------------ int main(int argc, char *argv[]) { int n; long long tab[1002]={0}; //printf("Dla ilu liczb chcesz policzyc NWD?: \n"); scanf("%d", &n); //printf("Podaj liczby: \n"); for (int i=0;i<n;i++) scanf("%I64d", &tab[i]); long long wynik=tab[0]; for (int i=0;i<n-1;i++) { wynik=nwd(tab[i],tab[i+1]); tab[i+1]=wynik; }
//printf("NWD wynosi %I64d \n", wynik); printf("%I64d", wynik);
system("PAUSE"); return EXIT_SUCCESS; } use __int64 instead long long |
what's wrong with that code :( | Bartosz | 1053. Пиноккио | 7 янв 2010 23:47 | 1 |
#include <cstdlib> #include <iostream> //----------Funkcje---------------------------- long long nwd(long long a, long long b) { if (b>=1) nwd(b, a%b); if (b=0) return a; } using namespace std; //---------------Program------------------------------------ int main(int argc, char *argv[]) { int n; long long tab[1002]={0}; //printf("Dla ilu liczb chcesz policzyc NWD?: \n"); scanf("%d", &n); //printf("Podaj liczby: \n"); for (int i=0;i<n;i++) scanf("%I64d", &tab[i]); long long wynik=tab[0]; for (int i=0;i<n-1;i++) { wynik=nwd(tab[i],tab[i+1]); tab[i+1]=wynik; }
//printf("NWD wynosi %I64d \n", wynik); printf("%I64d", wynik);
system("PAUSE"); return EXIT_SUCCESS; } |
How is it possible that the answer is IMPOSSIBLE? | Krzysztof "Doodge" Drozdz | 1053. Пиноккио | 21 сен 2009 01:06 | 3 |
Can anyone give me a test for which the answer is "impossible"? > Can anyone give me a test for which the answer is "impossible"? it impossible that "IMPOSSIBLE" |
JUDGES! The 1st word: "farther" instead "father"! | BlackShark | 1053. Пиноккио | 6 апр 2009 11:09 | 2 |
|
whi i got CE | I am david. Tabo. | 1053. Пиноккио | 15 фев 2009 18:07 | 4 |
#include int gcd( int a, int b ){ return b ? gcd( b, a%b ) : a; } int main () { int n, L, g=0; cin >> n; while( cin >> L ) g=gcd( L, g ); cout << g << endl; } include what? gcd is wrong too! #include <iostream> using namespace std; int gcd( int a, int b ) { return b ? gcd( b, a%b ) : a; } int main () { int n, L, g=0; cin >> n; while( cin >> L ) g=gcd( L, g ); cout << g << endl; } Change your code to this and it runs perfectly! Not complited first line, i suppose: #include (what??) |
why compilation error? if both gcc and intel c/c++ can compile | junmin | 1053. Пиноккио | 3 окт 2008 12:12 | 2 |
#include <stdio.h> #include <stdlib.h> int compare(const int *, const int *); int gcd(int, int); int main(void) { int size = 0,counter = 0; scanf("%d",&size); int ls[size]; int * pointer = ls; while(counter < size) { scanf("%d", pointer++); counter++; } qsort(ls, size, sizeof(int), compare); int x = ls[0]; while(--counter > 0) { x = gcd(x, ls[counter]); } printf("%d", x); return 0; } int gcd(int small, int big) { if (small == 0) return big; return gcd(big % small, small); } int compare(const int *p1, const int *p2) { int x = *p1; int y = *p2; if(x < y) { return -1; } else { return 1; } } ===================== 2904ea07-b44d-48c6-ba40-3b3f94228782 2904ea07-b44d-48c6-ba40-3b3f94228782(11): error: declaration may not appear after executable statement in block int ls[size]; ^ 2904ea07-b44d-48c6-ba40-3b3f94228782(11): error: expression must have a constant value int ls[size]; ^ 2904ea07-b44d-48c6-ba40-3b3f94228782(12): error: declaration may not appear after executable statement in block int * pointer = ls; ^ 2904ea07-b44d-48c6-ba40-3b3f94228782(18): warning #167: argument of type "int (*)(const int *, const int *)" is incompatible with parameter of type "int (__cdecl *)(const void *, const void *)" qsort(ls, size, sizeof(int), compare); ^ 2904ea07-b44d-48c6-ba40-3b3f94228782(19): error: declaration may not appear after executable statement in block int x = ls[0]; ^ 2904ea07-b44d-48c6-ba40-3b3f94228782(47): warning #1: last line of file ends without a newline } ^ compilation aborted for 2904ea07-b44d-48c6-ba40-3b3f94228782 (code 2) ============= junmin@thinking ~/workspace/otros/ACM $ gcc --version gcc (Gentoo 4.3.1-r1 p1.1) 4.3.1 Copyright (C) 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. junmin@thinking ~/workspace/otros/ACM $ icc --version icc (ICC) 10.1 20080801 Copyright (C) 1985-2008 Intel Corporation. All rights reserved. thanks!!!! Edited by author 02.10.2008 23:11 Your code: int compare(const int *, const int *); Right code: int compare(const void *, const void *); Your code: int ls[size]; Right code: int *ls = new int[size]; I wonder, where have you found C/C++ compiler which can successful compile it. =) My MinGW-gcc 3.4.2, Visual 2003, Visual 2005, Mandriva-gcc 3.4.2 say "Compilation error" |
Has anyone solved this? (Please HELP). Explain me the problem, please | Simeon Kostenski | 1053. Пиноккио | 8 июл 2007 20:41 | 5 |
Can anyone explain me the problem. Minimal numbers????????????????? What on earth is that. I have gone throuh he webboard but found nothing answering my question. I just can't understand where the mistake is. In my program? I don't know. But either the example or the algorithm explained is absolutely wrong. Tell me please :) heh... I didn't got the clue when I have been solving it, my program of course solved it OK, but it worked 500ms while other's programs worked 20-30 ms :) >Only find NOD of all pairs of numbers >2 and 4 has NOD 2 e.t.c. What the hell is a NOD on earth!!! Can someone explain? NOD = GCD (Greatest Common Divisor) (I think) I guess it is from russian (for example in bulgarian it is NOD too, and the languages are close) |
I don't understand this "If lengths of the blanks are different, then..." | Dilyan | 1053. Пиноккио | 8 июл 2007 01:10 | 2 |
If lengths of the blanks are different, then the piece of the most long blank is sawed off and its length must be equal to the length of the other blank. Then the algorithm is repeated from point 2.??? what does it mean Edited by author 15.05.2005 19:59 yes. whose length must be equal to the length of the other? The sawed off part or the remaining part??? |
What's a blank? | xerxe | 1053. Пиноккио | 15 янв 2007 19:51 | 2 |
Don't they mean planks ? :) |
SOS! | Amy | 1053. Пиноккио | 21 окт 2006 01:27 | 2 |
SOS! Amy 18 июл 2003 15:26 This is my programme,please tell me why I got WA.Thank you! var n,m,m0,ys:longint; procedure pd(a,b:longint); var t:longint; begin if a<b then begin t:=b; b:=a; a:=t; end; while a mod b<>0 do begin a:=a mod b; t:=a;a:=b;b:=t; end; ys:=b; end; procedure run; var i:integer; begin for i:=1 to n-1 do begin readln(m); pd(m0,m); m0:=ys; end; writeln(ys); end; begin readln(n); read(m0); run; end. Maybe replace readln to read |
what they programme only use 60k memory with c++ ? | Aply | 1053. Пиноккио | 1 фев 2006 16:22 | 2 |
who know please tell me ? give me a sample programme is the best! var a:array[1..1000]of longint; n,i,j:longint; function nod(k,l:longint):longint; begin repeat if k<l then l:=l mod k else k:=k mod l; until (k=0)or(l=0); nod:=k+l; end; begin read(n); for i:=1 to n do read(a[i]); for i:=n-1 downto 1 do a[i]:=nod(a[i],a[i+1]); write(a[1]); end. |
Wrong Example | Tabledott | 1053. Пиноккио | 27 дек 2005 14:32 | 2 |
I'm quite sure that either the example or the problem statement is wrong....Is it possible to correct them? I've replaced "Let's choose 2 blanks with minimal numbers" with "Let's choose some 2 blanks" Is problem ok now? Edited by author 27.12.2005 14:42 |