Общий форумПоясните пример, пожалуйста Холден - не 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 var n,i,j,k:integer; s,h,g,r:string; a:array[1..200] of string; begin s:='Slytherin'; h:='Hufflepuff'; g:='Gryffindor'; r:='Ravenclaw'; readln(n); for i:=1 to 2*n do readln(a[i]); writeln(s,':'); for i:=2 to 2*n do if a[i]=s then writeln(a[i-1]); writeln; writeln(h,':'); for i:=2 to 2*n do if a[i]=h then writeln(a[i-1]); writeln; writeln(g,':'); for i:=2 to 2*n do if a[i]=g then writeln(a[i-1]); writeln; writeln(r,':'); for i:=2 to 2*n do if a[i]=r then writeln(a[i-1]); end. a:array[1..2000] of string; If n = 3 then general headquarters are NOT able to form the three-man groups from the rest of fighters so that every group will contain at least one teddyhater. So, it seems that correct answer should be 0 for n =3 (test #2) Actually it should be 1, because he HAS to think for 1 minute to join the group, also general headquarters are able to form a three-man group, because n=3=2+Holden. headquarters are NOT able to form the three-man groups from the REST of fighters. Rest of fighters = 0, so NOT able to form the three-man groups. Holden тоже может быть teddyhater ом? They CAN form 0 groups, so that EACH OF THESE 0 GROUPS will contain teddyhater Tests with n = 3 are removed. n >=6 in the statement now. Какие ограничения накладываются на c[i]? Какой максимальной длины может быть это число? 2*3*5*7*11*13*17*19*23*29*31*37*41*43*47 Edited by author 28.10.2012 11:22 Edited by author 28.10.2012 11:22 Edited by author 28.10.2012 11:22 Holden! Why do you fight with teddybears? They are so cute... They just want to live in peace... And you! You want to annihilate them! Damn you, Holden! #include <iostream> #include <string> #include <stdlib.h> using namespace std; int main() { string s; char ss[10]; short l, i; int ostatok = 0, mnojitel = 1; cin >> s, ss; while (i < s.length() / 8) { l = s.copy(ss, 8, i*8); ss[9] = '\0'; ostatok = (ostatok * 100000000 + atoi(ss)) % 7; i++; } for (l = 0; l < s.length() - i*8; l++) mnojitel *= 10; l = s.copy(ss, s.length() - i*8, i*8); ss[s.length() - i*8] = '\0'; ostatok = (ostatok * mnojitel + atoi(ss)) % 7; cout << ostatok << endl; return 0; } It's work on my PC and give true results for input data from "Test Cases" why is the output YES? there are two B in the first row of output. |
|