Общий форумPlease, give some testdata This is my code: program num_1510; type ar = array of longint; var N,i,j,c,a:longint; arr,arr2,arr3:ar; pow:boolean; BEGIN read(N); setlength(arr,N+2); setlength(arr2,N+2); setlength(arr3,N+2); for i:=1 to N do read(arr[i]); arr2[1]:=arr[1]; c:=1; for i:=1 to N do begin for j:=1 to N do begin if arr2[j]=arr[i] then begin pow:=false; break; end else begin pow:=true; end; end; if pow then begin arr2[c]:=arr[i]; c:=c+1; end; end; for i:=1 to N do begin for j:=1 to N do begin if arr[i]=arr2[j] then c:=j; end; arr3[c]:=arr3[c]+1; end; a:=arr3[1]; for i:=1 to N do begin if a>arr3[i+1] then a:=a else a:=arr3[i+1]; end; for i:=1 to N do begin if a = arr3[i] then begin a:=i; break; end; end; write(arr2[a]); END. Please, help me:) Edited by author 01.11.2012 00:53 var a,b,c,d:integer; begin read(a,b,c,d); if ((a-b=0)or(a-c=0)or(a-d=0)) and((b-a=0)or(b-c=0)or(b-d=0)) and((c-a=0)or(c-b=0)or(c-d=0)) and((d-a=0)or(d-b=0)or(d-c=0)) then writeln('yes') else writeln('no'); end. Test#11 4 10 4 2497 Out - 10 10 10 2 What's wrong? Help!!! I think the res is : 10 10 10 10 Don't use int. Use long long. Edited by author 31.10.2012 15:46 My program got Crash (assert), cause this test has some trash in the end. Валят первым тестом, вроде работает #include <stdio.h> void main() { int i=0,cash=0; char text[1000]; gets(text); while(text[i]!=NULL && i<1001) { if (text[i]=='a' || text[i]=='d' || text[i]=='g' || text[i]=='j' || text[i]=='m' || text[i]=='p' || text[i]=='s' || text[i]=='v' || text[i]=='y' || text[i]=='.' || text[i]==' ') cash+=1; if (text[i]=='b' || text[i]=='e' || text[i]=='h' || text[i]=='k' || text[i]=='n' || text[i]=='q' || text[i]=='t' || text[i]=='w' || text[i]=='z' || text[i]==',') cash+=2; if (text[i]=='c' || text[i]=='f' || text[i]=='i' || text[i]=='l' || text[i]=='o' || text[i]=='r' || text[i]=='u' || text[i]=='x' || text[i]=='!' ) cash+=3; i++; } printf("%d",cash); } Edited by author 30.10.2012 18:58 Поясните пример, пожалуйста Холден - не Hater. Holden is no hater тогда посмотрим на отряды с его участием: look at the companies with Holden. 1.1 2 3 2.1 2 4 3.1 2 5 4.1 2 6 5.1 3 4 6.1 3 5 7.1 3 6 8.1 4 5 9.1 4 6 10.1 5 6 всего Hater-ов 4, поэтому даже если задействовать здесь 2х, то останутся двое на следущую группу. A count of Haters is 4. If we use 2 haters in one group then we have other haters to other group #include <iostream> int fow(int n,int m) {int s=1; for(int i=0;i<m;i++) {s=s*n;} return s; } int main() {int x=0,y,m,n; std::cin>>n>>m>>y; for(int i=0;i<m;i++) { if(fow(i,n)%m==y) {std::cout<<i<<' '; x=1;} } if(x==0) std::cout<<"-1"; return 0; } this my solution: #include <iostream> #include <string> #include <stdlib.h> #include <algorithm> using namespace std; int main(){ int bilo; string s; cin>>s; for (int j = 0; j < s.length() - 1; j++){ bilo = 0; for (int i = 0; i < s.length()-1; i++){ if (s[i] != '1') if ((s[i] == s[i+1])){ s[i] = '1'; s[i+1] = '1'; bilo = 1;
if (i < s.length()-1){ rotate(&s[i], &s[i+1], &s[i] + s.length() - i); rotate(&s[i], &s[i+1], &s[i] + s.length() - i); } } } if (bilo = 0) break; }
int i = 0; while (s[i]!='1'){ cout<<s[i]; i++; }
//system("pause"); return 0; } please send me answer on my e-mail: sergeo_91_@mail.ru or write me here. P.S. thank you in advance. i use BFS and can't pass test 8 because MLE help me, please Edited by author 30.10.2012 09:44 В условии почему-то не упоминается что команда сплочённая ещё и когда она состоит из всех людей и при этом эффективная. - Edited by author 28.10.2012 12:52 Edited by author 29.10.2012 20:47 If i input 4, what is answer? or if i input 8, what answer? Agreed, it is good to have some basic problems for beginners. #include<iostream> #include<cstdlib> using namespace std; int main(){ int i,j,n,m,k; for(i=0;i<1000000;i++){ k=rand()%26; k+=97; cout<<(char)k; } //cin.get(); return 0; } Why do you have as a result is 31, not 32. please make sure that! Read the condition of the problem more carefully: "If there is no money in the budget then applications are not accepted any more." Что для центров важнее: получить больше прибыли или минимизировать прибыль соперника? More money is more important than make less money to opponent. Don't use any collections (TreeSet/HashSet/etc) (ArrayList might also be a problem) looks like when they add/remove/update their elements they do some stuff to their elements, so that doubles change their magnitude. u might also try to use YouOwnDouble class implements Comparable using collections gives AC so u r mad What is it Use these tests: 4 4 -> 6 5 4 -> 7 4 5 -> 6 1 9 -> 0 9 1 -> 1 I think that you miscalculated the answer at the second example.It's 8,isn't it ? Use these tests: 5 4 -> 8 |
|