| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| WA3 in C++ Anyone could help me?? | zimozi | 1881. Длинное условие задачи | 26 июл 2015 07:24 | 1 |
#include <iostream> #include <string> using namespace std; int main() { int h,w,n,page=1; int count = 0; int a = 0; cin>>h>>w>>n; string str; for(int i = 1;i <=n;i++) { cin>>str; count+= str.length()+a; if(count> w) { count = str.length(); a = 1; page++; } else if(count ==w) { count = 0; a =0; if(i<n) page++; } else { a++; } } if(page%h==0) cout<<page/h; else cout<<((page/h)+1); return 0; } |
| WA 10 and I have no idea what could be wrong | MishaRash | 1201. Какой сегодня день? | 25 июл 2015 00:56 | 2 |
I wrote the program on Python 3.4. The output for '30 1 2012' is mon........2....9...16...23..[30] tue........3...10...17...24...31 wed........4...11...18...25..... thu........5...12...19...26..... fri........6...13...20...27..... sat........7...14...21...28..... sun...1....8...15...22...29..... It should be right, but I still got WA. I think there is too few data about the output format in the problem statement. For example, I had to go to forum to get that there must be 4 spaces between first and second coulumn and no space in the end of the second line in this case. I rewrote the program on C (GCC) and found the problem. On '1 1 1600' I got mon........3...10...17...24 tue........4...11...18...25 wed........5...12...19...26 thu........6...13...20...27 fri........7...14...21...28 sat.[.1]...8...15...22...29 sun...2....9...16...23...30 My program calculated number of weeks in the month wrong. When I solved this, I got AC. Probably the 10th test is not '30 1 2012' any more. |
| No subject | SRC | 1079. Максимум | 23 июл 2015 21:00 | 1 |
Edited by author 23.07.2015 23:40 |
| hints | 6ahodir | 1005. Куча камней | 23 июл 2015 11:42 | 8 |
hints 6ahodir 24 сен 2012 12:12 A very good resource, but it still very hard for me to understand though...:( very thanks, I understood! Thanks for the hints: using dynamic programming. Re: hints Ealham Al Musabbir 23 июл 2015 11:42 |
| Difficulty | Marius Žilėnas | 1084. Пусти козла в огород | 23 июл 2015 03:05 | 2 |
Simple but interesting problem. There are two ways to find angle: geometrically (i made it this way) or computationally :). |
| Test #3 | Elinchik | 1021. Таинство суммы | 22 июл 2015 23:57 | 6 |
Что такое тест № 3? мой алгоритм не прошел этот тест!!! Вообще где найти разъяснения к номерам тестов?? какие-такие разъяснения? раз не прошел 3 тест значит где-то у тебя косяк. Никакой не косяк. Реально тест №3 неправильный. Вот корректное решение: считываем в два массива А и В. Потом цикл по элементам А, и для каждого А(и) пытаемся найти такое В(ж), чтобы А(и)+В(ж)==10000. И получаем ВА. Бред. (поиск бинарный так как отсортированы массивы). #include <iostream> using namespace std; int cmp(const void*A,const void *B){ long t=*(long*)A-*(long*)B; if (t>0) return 1; if (t==0) return 0; if (t<0) return -1; } int main(void){ long N,M,i,j; long *A,*B; long * C; cin>>N; A=new long[N]; for(i=0;i<N;i++) cin>>A[i]; cin>>M; B=new long[M]; for(i=0;i<M;i++) cin>>B[i]; bool t=false; for(i=0;i<N;i++) { j=10000-A[i]; C=(long*)bsearch(&j,B,M,sizeof(long),cmp); if(C!=NULL) if(A[i]+*C==10000){t=true; break;} } if(t)cout<<"YES"; else cout<<"NO"; cout<<endl; system("pause"); return 0; } Очевидно условия некорректны. В условии сказано,что массивы упорядочены. Но достаточно дописать в мое решение qsort(A,N,sizeof(long),cmp); qsort(B,M,sizeof(long),cmp); И вуаля все просто, и получаем АС. Авторы проверяйте условия, или хотя бы читайте форум иногда. Тут нередко попадаются задачи с корявыми тестами, которых не должно быть по условию. Edited by author 03.12.2010 03:00 Процедура bsearch предполагает, что массив должен быть отсортирован в неубывающем порядке, мне не совсем понятен твой компоратор, фактически он ничего не меняет, так процедура bsearch и сравнивает по умолчанию. То есть когда ты отсортировал массив по своему компоратору, ты, фактически, инверитровал его и привел к такому виду, что процедура bsearch будет работать правильно. Попробуй на своей первоначальной программе: 9 3 5 15 20 100 900 5000 9983 15000 9 7000 549 58 17 8 4 0 -10 -30 Правильный ответ: ΥΕS (9983+17) И да:"Если вы не можете решить задачу, значит вы не можете её решить". Re: Test #3 BrainFuck [UFU SESC bash.org/I'ja] 25 апр 2013 18:39 попробовал на своей программе #include <iostream> using namespace std; int main() { int n; cin >> n; int *a = new int[n*2]; for (int i = 0; i < n*2; i++) cin >> a[i]; for (int i = 0; i <n; i++) for (int j = n; j < n*2; j++) if (a[i]+a[j] == 10000) { cout << "YES" << endl; delete [] a; exit (0); } cout << "NO" << endl; delete [] a; return 0; } Выдало YES, к тому же такой алгоритм хоть и можно назвать затратным, но он рабочий. |
| есть у кого контрпример? | Anonymous | 2061. OEIS A216264 | 22 июл 2015 18:42 | 3 |
Кто в теме, приведите хотя бы один пример НЕбогатой строки. Буду признателен Спасибо. И поздравляю как первого (и пока единственного) решившего) |
| I've got WA 4 | Muravjev Slava [Samara SAU] | 1050. Подготавливая статью | 22 июл 2015 14:00 | 2 |
Give me some tests or advices, please. Got WA4, cause ignore situation \par" Input: There is no "q in this sentence. \par" "Talk child," said the unicorn. She s\"aid, "\thinspace `Enough!', he said." \endinput Output: There is no q in this sentence. \par`` ''Talk child, said the unicorn. She s\"aid, ``\thinspace `Enough!', he said.'' \endinput |
| Problem without problem statement!!! | [SPbSU ITMO] MAKAPOB | 1201. Какой сегодня день? | 21 июл 2015 22:27 | 3 |
To admins: please add some rules, which format of output should be, because this example from one month shows me nothing. 1) number of spaces must be 3 everywhere except 1,2,3,4,5,6,7,8,9? 2) we must count day of week using normal calender? Rules about it are full, or some items are omitted??? 3) What is in test 10?? P.S. Is this correct for: 7 1 2006 mon.......2....9...16...23...30 tue.......3...10...17...24...31 wed.......4...11...18...25 thu.......5...12...19...26 fri.......6...13...20...27 sat.....[.7]..14...21...28 sun...1...8...15...22...29 Or correct is: mon........2....9...16...23...30 tue........3...10...17...24...31 wed........4...11...18...25 thu........5...12...19...26 fri........6...13...20...27 sat......[.7]..14...21...28 sun...1....8...15...22...29 ????? I mean number of spaces. Edited by author 03.03.2007 11:41 I think you should not count space characters but rather use alignment like in sample. The problem is that there is no information about this case in samples. |
| whats wrong here please ? | MyName | 1001. Обратный корень | 21 июл 2015 18:24 | 2 |
#include <iostream> #include <string> #include <cstdlib> #include <cmath> #include <sstream> #include <vector> #include <stdio.h> using namespace std; int main() { string s=""; vector <long double> vec; cout<<vec.size(); long double j; char c; stringstream ss(""); for (int i=0;i<256000;i++)//This is here so I can handle the size of the stream input { cin.get(c); s+=c; } //Now I know I am working on 256KB ss<<s; while(ss>>j) { j=sqrt(j); vec.push_back(j); } for (int k=vec.size()-1;k>=0;k--) { cout.precision(4); cout<<fixed<<vec[k]<<endl; } return 0; } I should add a test, if we are in the end of file before the 256000. Otherwise, it'll wait for 256000 char to enter |
| java AC in the top of ranks | esbybb | 1413. Марсопрыг | 21 июл 2015 11:37 | 1 |
InputStream is = System.in; byte[]b = new byte[1000_001]; int L = is.read(b)-1; while(b[L]<48 || b[L]>57) L--; int i=0; double D = Math.sqrt(0.5); double x=0; double y=0; // 1 2 3 4 5 6 7 8 9 double[] shftx = new double[]{0,-D, 0, D,-1, 0, 1,-D, 0, D}; double[] shfty = new double[]{0,-D,-1,-D, 0, 0, 0, D, 1, D}; while(i<=L && b[i]!=48 && b[i]!=0){ x+=shftx[b[i]-48]; y+=shfty[b[i]-48]; i++; } System.out.println(String.format("%.10f %.10f", x, y)); |
| wa3 | Fyodor Menshikov | 1721. Две стороны одной монеты | 20 июл 2015 13:25 | 2 |
wa3 Fyodor Menshikov 31 окт 2010 01:44 Pairs in output should be ordered: in each pair first the name of a person writing the statement and then the name of a person preparing the tests. Solution printing unordered pairs gets wa3. Re: wa3 Zakharov Konstantin 20 июл 2015 13:25 My solution got wa1 because of this)) |
| Any hints for wa-4? | Mullabaev | 1434. Автобусы города Васюки | 18 июл 2015 15:07 | 1 |
|
| WA14 | sherbina_evgeniy | 1721. Две стороны одной монеты | 17 июл 2015 23:34 | 1 |
WA14 sherbina_evgeniy 17 июл 2015 23:34 I got WA 14. I don't understand why? Please give me some tests or explain where is my mistake. |
| Где ошибка? С++ | NoNSoS | 1068. Сумма | 16 июл 2015 12:49 | 1 |
#include <iostream> using namespace std; int main (){ int a; int sum; cin >> a; if (a<1 && a>=-10000){ for (int i = 1; i >= a; i--){ sum = sum + i; }; } else if (a>=1 && a<=10000) { for (int i = 1; i <= a; i++){ sum = sum + i;
}; }; cout << sum; return 0; } при: N(a) -- sum 10000 -- 50005000 1 -- 1 0 -- 1 -1 -- 0 -3 -- -5 -10000 -- 50004999 Edited by author 16.07.2015 12:55 Edited by author 16.07.2015 12:56 |
| What is wrong? Что не так? // С++ | Kelife | 1000. A+B Problem | 15 июл 2015 21:22 | 4 |
#include <iostream> using namespace std; int main() { int a, b; cout << "Enter 'a': "; cin >> a; cout << '\n'; cout << "Enter 'b': "; cin >> b; cout <<'\n'; cout << a + b; return 0; } Edited by author 07.06.2015 21:38 Edited by author 07.06.2015 21:38 Don't output "Enter a" or something like that Don't output "Enter a" or something like that Значения a и b вводятся через пробел, поэтому надо использовать только cin >> a >> b; |
| Please, help! | Shaft | 1327. Предохранители | 15 июл 2015 20:05 | 1 |
I can't understand what's wrong in my code, it write 51 instead of 50 #include <iostream> using namespace std; int main() { unsigned short a, b, c; cin >> a >> b; c = (b - a) + 1; if(c % 2 == 0) cout << c / 2; else cout << (c / 2) + 1; /// 1! 2 3! 4 5! 6 7! 8 9! 10 11! 12 13! 14 15! return 0; } |
| THis is supposed to work. What is wrong? | Luigi Brito | 1001. Обратный корень | 15 июл 2015 11:29 | 3 |
#include <stdio.h> #include <math.h> main() { int a=0; float b=0; while (!feof(stdin)) { scanf("%d", &a); b=sqrt(a); if (feof(stdin)) printf("%.4f\n",b); } } It works fine at my PC. But it keeps saying wrong answer? #include <stdio.h> #include <math.h> main() { int a=0; float b=0; while (!feof(stdin)) { scanf("%d", &a); b=sqrt(a); printf("%.4f\n",b); } } You should use a long long data type, because the int type supports only 2^32 as max. Please, read the contraints of the problem. There says that the number could be as big as 10^18 (a lot bigger than 2^32). Try with long long. Hope it be useful for you. |
| Подводные камни "1001.Обратного корня" | Yegor | 1001. Обратный корень | 15 июл 2015 02:35 | 2 |
//if 'double s[130196]' before 'int main()' - all is OK!! //but if 'double s[130196]' in 'int main()' then Runtime error (stack overflow)!!!!!!! //------------------------------------------------- //AND MAGIC №2: //any number after 130196 (for example 130196,130197...) in 'double s[130196]' - all is OK!! //BUT numbers before 130196, for example 130195, 130194... then Runtime error (access violation)!!! //------------ //on the internet people use 'double s[131072]' - it is 2^17, why???? if i can use 130196 //------------------ #include <iostream> #include <iomanip> #include <cmath> using namespace std; double s[130196];// if 130195 or < then Runtime error (access violation)!!! int main() { //double s[130196]; - if in 'int main()' then Runtime error (stack overflow) int t = 0; while (cin>>s[t]){t++;} while(t>0){cout<<fixed<<setprecision(4)<<sqrt((double)s[--t])<<endl;} return 0; } //why why why ??)) Edited by author 14.07.2015 17:12 Array from main function is kept in stack memory, and this memory is limited. You should declare it as global, or increase stack size. |
| Runtime error in Java 1.7 test 2 help me please | Axmadjon | 1370. Волшебник | 14 июл 2015 22:30 | 2 |
import java.util.Scanner; public class _1370 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int digitos = in.nextInt(); int cliques = in.nextInt(); String saida = ""; String parte2 = ""; for (int i = 1; i <= cliques; i++){ saida += in.nextInt(); } for (int i = cliques+1; i <= digitos; i ++){ parte2 += in.nextInt(); } parte2 += saida; System.out.println( parte2.substring(0,10) ); } } you are using in.nextInt() to get the input from the user for a String. That is used for integers. You should be using in.next() or in.nextLine() for String. |