Общий форумplease say what is wrong #include <iostream.h> main() { int n,a,b,c,d,e,f; cin>>n; f=n%10; e=(n/10)%10; d=(n/100)%10; c=(n/1000)%10; b=(n/10000)%10; a=(n/100000)%10; cout<<a<<endl; cout<<b<<endl; cout<<c<<endl; cout<<d<<endl; cout<<e<<endl; cout<<f<<endl; if((a+b+c)-(d+f+e)==1 || ((a+b+c)-(d+f+e)==-1)) cout<<"yes"; else cout<<"no"; return 0; } Edited by author 01.05.2008 12:57 try test 123160 and 889789 You don't need to output a,b,c..., only print Yes or No. Edited by author 01.05.2008 13:28 how do this problem in c++? Edited by author 01.05.2008 12:55 Edited by author 01.05.2008 12:55 Читая различные обсуждения этой задачи, я нашел множество отклонений от условия... Так давайте верно переформулируем условие задачи! On reading posts about the problem, i've found many mistakes in defination... Lets make the defination correct! There is a dot after Impossible. This costed me 10 submits what are the real restrictions for input data? I just add in my source: n = (n - 1) % 20 + 1, and have WA test 1; else I have TL test 1. then I send the code: scanf("%i%i", &n, &m); for (i = 0; i < m; i++) { scanf("%i%i%lf", &a, &b, &c); while (a > 10000 || b > 10000); } return 0; and have TL test 1 Edited by author 28.04.2008 17:09 Anupam Ghosh,Bengal Engg and Sc Uni,MtechIT,2006-09,India got ac // Задача 1567. SMS-спам 28 апр 2008 16:38 this is a simple problem just try to find position of alphabet in a single button and add the value to sum.good luck. Are you going to add "How to write C# solutions" in FAQ ? What you should consider is that, there will be some extra spaces at the end of ONE line. And then you'll get AC easily. This code seems to solve the problem on my computer, but it I got WA on test#3! I've been trying for some hours to improve it. But I think I've already tried everything I know (which is certainly not too much!) Please, can you tell me what's wrong here? #include<iostream> #include<iomanip> #include<cmath> #include<cstdlib> using namespace std; int main() { const int size = 128000; int counter=0, max; double x; double* array = new double[size]; double* ptr = array;
cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(4); while(1) { cin>>x; if(cin.eof())break; counter++; (*ptr)=sqrt(x); if(counter < size) ptr++; } if(counter < size) ptr--; max = counter; for(counter=max;counter > 0;counter--) { cout<<*ptr<<endl; ptr--; }
return 0; } If there is at least one empty cell, every cell could be covered more than one way, and there is a way to cover all the cells, there is another way to cover all the cells? Your reasoning is wrong. I give you example. Could you find more than one way for cover this cells? 110000 011000 001100 000000 000000 000000 this case works, only by making "one-way" steps i can fill the board, 11GGEE 211FFD 2311CD 4388CB 46699B 5577AA note that "EVERY cell could be covered more than one way" in your case this wrong for cell (2,1) Edited by author 27.04.2008 02:03 I'm getting WA#11 Is there anyone who had such problem and got AC after rectifying it. Is there any such tricky test case. Problem solved. Try this test case 0 13 answer should be 1 8191 10000 i use a standart rec function may be something wrong with input (cin >> s;) may be another. Can you give me 7th test to check this? #include<iostream> using namespace std; unsigned long long n=36; int k; int main() { cin>>k; while(k>1) { n*=55; k--; } cout<<n<<endl; } Why this code gives WA3?????? I don't know why? [code deleted] Edited by author 26.04.2008 22:14 hi! really i can't understand it. who can explain it to me with some examples, please!! thanks!! My program run in 0.741 seconds and i saw most people only needed 0.09s. How can i solve this any faster? var d:array[1..50000] of integer; n,m,i,j,k:longint; begin fillchar(d,sizeof(d),0); readln(n,m); for i:=m+1 to n do begin k:=i; for j:=2 to trunc(sqrt(k)) do while k mod j=0 do begin inc(d[j]); k:=k div j; end; if k<>1 then inc(d[k]); end; for i:=1 to n-m do begin k:=i; for j:=2 to trunc(sqrt(k)) do while k mod j=0 do begin dec(d[j]); k:=k div j; end; if k<>1 then dec(d[k]); end; k:=0; for i:=2 to n do if d[i]>0 then inc(k); writeln(k); end. > My program run in 0.741 seconds and i saw most people only needed > 0.09s. How can i solve this any faster? > > var d:array[1..50000] of integer; > n,m,i,j,k:longint; > begin > fillchar(d,sizeof(d),0); > readln(n,m); > for i:=m+1 to n do begin > k:=i; > for j:=2 to trunc(sqrt(k)) do > while k mod j=0 do begin > inc(d[j]); k:=k div j; > end; > if k<>1 then inc(d[k]); > end; > for i:=1 to n-m do begin > k:=i; > for j:=2 to trunc(sqrt(k)) do > while k mod j=0 do begin > dec(d[j]); k:=k div j; > end; > if k<>1 then dec(d[k]); > end; > k:=0; > for i:=2 to n do > if d[i]>0 then inc(k); > writeln(k); > end. > 0.001s, 336kb. Use following fact from the number theory: Power of each prime in binomial coefficient's factorization equals to the number of borrows in the substraction n-k in base p. Iterate all primes less then N and count it if prime will greater then 0; code deleted Edited by author 26.04.2008 01:46 |
|