Common Board#include <iostream>; #include <vector>; using namespace std; int main() { vector<int> v; int n; while (std::cin >> n) v.push_back(n); int i; for(i = v.size() - 1; i>=0; i--) printf("%.4f\n", sqrt((double) (v[i]))); system("pause"); return 0; } P.S. А тесты на которых проверяются программы можно увидеть? Hey dude, did you read FAQ? Why did you decide to include system("pause") in your code? Do you think it will help testing system to check your code??? I delete it when I check, but forget to delete, when copy it here Edited by author 16.06.2013 16:22 Edited by author 16.06.2013 16:22 Edited by author 16.06.2013 16:22 Ты вроде Сергей, почему по русски не ответил? Edited by author 16.06.2013 16:23 У меня тоже самое: в консоли числа совпадают с ответом для первого теста, а в результатах проверки Wrong answer У меня сейчас немного изменилось положение, я понял, что не совсем понимаю, как должен заканчиваться поток данных. Я например его завершаю нажатием ctrl+z, понятия не имею откуда я это знаю, видно некоторые знания в университете попадают в голову в не зависимости от моего желания) Так вот, я обычно тестил и завершал этим, а сейчас ввожу первую строку ,потом вторую допустим 4444444444 4444444444444 и поток завершается сам собой, причем ответ только для одного числа, т.е. ошибку вроде нашел, но как с ней бороться не знаю. Use files to test your program locally I used files for testing and got an error in the first test. My answer is the same as in example. Also I used in my testing text from example. Вот мой код. Замени int на double в векторе и n #include <stdio.h> #include <conio.h> #include <algorithm> #include <iostream> #include <iomanip> #include <math.h> #include <vector> #include <set> #include <map> #include <queue> #include <deque> #include <string> using namespace std; int gcd (int a, int b){ return (b)? gcd(b,a % b) : a; } int lca (int a, int b){ return a / gcd(a,b) * b; } int main() { vector <long double> a; long double n = 5.0; while(cin >> n) a.push_back(n); for(int i = a.size() - 1;i >= 0; --i) cout << fixed << setprecision(4) << pow(double(a[i]), 0.5) << endl; return 0; } Первый тест - это ввод исходных данных из примера и ожидание вывода результата примера. А число 876652098643267843 уже больше значений типа int. Поэтому первый тест ломается уже на сканировании этого числа в переменную n. 876652098643267843 влазит в тип long long int I cant find my mistake please help me what is test 5. Edited by author 19.10.2013 17:12 What a bad problem it is! It is more like a reading comprehension problem in an English exam than a programming problem! Что означает Problem locked? Problem will be unlocked in 5 minutes. Sorry. Do the segments include their endpoints? what's wrong in my code: #include <iostream> int main() { int N; std::cin >> N; int result=0; if (N=0){ std::cout << 1 << std::endl; return 0; } if (N > 0) { for (int i=2; i<=N;i++) { result+=i; } std::cout << result << std::endl; return 0; }else { for (int i=-2;i >=N;i--) { result+=i; } std::cout << result << std::endl; return 0; } return 0; } Edited by author 18.10.2013 23:00 I saw many guys got AC very fast,is there any way to work the problem out other than just find-cycle? There is a catch, you should account for three situations: 1) N > 0 2) N < 0 3) N == 0 <--- 8-D. Small assignment, but took an hour of trying. you could just come up with the relatively less error-prone solution in one line for(int i = 1; i!=N+2*(N>0)-1; i+=2*(N>0)-1) sum+=i; Edited by author 16.11.2013 15:47 I think that code is easy to understand. If you got WA, try it. #include <iostream> #include <map> using namespace std; int main() { map<char, string> m; int n; cin >> n; while (n--) { char c1, c2; cin >> c1 >> c2; m[c1].push_back(c2); } char c; cin >> c; for (int i = 0; i < m[c].size(); ++i) cout << c << m[c][i] << endl; return 0; } #include <iostream> using namespace std; int main () { short int i, n1, n2, n3; cin >> i; cin.sync(); char *name1, *name2, *name3, *name = new char[20]; n1 = n2 = n3 = 0; name1 = "Emperor Penguin"; name2 = "Macaroni Penguin"; name3 = "Little Penguin"; while (i > 0) { cin.getline(name,19); cin.sync(); switch(name[0]) { case 'E': n1++; break; case 'M': n2++; break; case 'L': n3++; break; } i--; } if (n1 > n2 && n1 > n3) printf("%s",name1); else if (n2 > n1 && n2 > n3) printf("%s",name2); else if(n3 > n1 && n3 > n2) printf("%s",name3); system("pause"); return 0; } used STL multimap and scanf,printf instead cin,cout got AC 0.5 sec ;) I think use a struct and sort in STL will be easier to code. Must add length to the final result. Solve it with brute force, afaik this problem is of NP class. import java.util.*; public class My { public static void main(String[] args) {
Scanner in = new Scanner(System.in); int a = in.nextInt();
if ((a >= 1) && (a <= 4)){ System.out.println("few"); } else if ((a >= 5) && (a <= 9)){ System.out.println("several"); } else if ((a >= 10) && (a <= 19)){ System.out.println("pack"); } else if ((a >= 20) && (a <= 49)){ System.out.println("lots"); } else if ((a >= 50) && (a <= 99)){ System.out.println("horde"); } else if ((a >= 100) && (a <= 249)){ System.out.println("throng"); } else if ((a >= 250) && (a <= 499)){ System.out.println("swarm"); } else if ((a >= 500) && (a <= 999)){ System.out.println("zounds"); } else if (a > 1000){ System.out.println("legion"); }
} } Please help me!!! Well, try these: 11 01011100000 01111011001 10 1001110000 0011111010 10 1001111110 0000011010 They should n't be impossible. Edited by author 31.08.2007 16:17 Edited by author 15.10.2013 21:28 Edited by author 15.10.2013 21:28 i guess the right way is like AAB AAB BBC Edited by author 25.01.2013 16:44 You think wrong, this example can be covered with only 2 letters. Brute force (полный перебор) method gives Time Limit Exceeded. In Java it takes 6 seconds to for parameters N=8, K=10. So the clever method (which uses recurrent calls) is the way to go. |
|