| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| Help!!!! - WA on Test 14 | gubbarr | 1073. Квадратная страна | 11 июн 2012 09:15 | 1 |
I get WA on Test 14, some can help me with this? Here's my code. #include <iostream> #include <math.h> int solve( float val_p ) { int id = 0, sqr = 0, seqCount = 0, bestCount = 9999, maxVal = val_p, n = (int)sqrt( val_p ); for( int seqID = n; seqID > n/2; seqID-- ) { id = seqID; maxVal = val_p; seqCount = 0; while( id > 0 ) { sqr = id*id; --id; if ( maxVal >= sqr ) { maxVal -= sqr; id = sqrt( float( maxVal ) ); if ( ++seqCount > bestCount ) break; } } bestCount = std::min( bestCount, seqCount ); }; return bestCount; }; int main() { unsigned int val = 0; while( std::cin >> val ) { if ( val > 60000 || val <= 0 ) break; std::cout << solve( val ) << std::endl; } return 0; } |
| wa 8 | garra | 1792. Код Хэмминга | 9 июн 2012 13:19 | 2 |
wa 8 garra 9 июн 2012 11:06 #include<stdio.h> #include<stdlib.h> int main() { int a[8],i,q1=0,q2=1,q3=2,q4=3,r1=4,r2=5,r3=6; for(i=0;i<7;i++) { scanf("%d",&a[i]); } if((a[q2]+a[q3]+a[q4])%2==a[r1]&&(a[q1]+a[q3]+a[q4])%2==a[r2]&&(a[q1]+a[q2]+a[q4])%2==a[r3]) { for(i=0;i<7;i++) { printf("%d",a[i]); printf(" "); } } else if ((a[q2]+a[q3]+a[q4])%2!=a[r1]&&(a[q1]+a[q3]+a[q4])%2!=a[r2]&&(a[q1]+a[q2]+a[q4])%2==a[r3]) { if(a[q3]==1) { a[q3]=0; } else { a[q3]=1; } for(i=0;i<7;i++) { printf("%d",a[i]); printf(" "); } } else if((a[q2]+a[q3]+a[q4])%2!=a[r1]&&(a[q1]+a[q3]+a[q4])%2==a[r2]&&(a[q1]+a[q2]+a[q4])%2!=a[r3]) { if(a[q2]==1) { a[q2]=0; } else { a[q2]=1; } for(i=0;i<7;i++) { printf("%d",a[i]); printf(" "); } } else if((a[q2]+a[q3]+a[q4])%2==a[r1]&&(a[q1]+a[q3]+a[q4])%2!=a[r2]&&(a[q1]+a[q2]+a[q4])%2!=a[r3]) { if(a[q1]==0) { a[q1]=1; } else { a[q1]=0; } for(i=0;i<7;i++) { printf("%d",a[i]); printf(" "); } } else { if(a[q4]==1) { a[q4]=0; } else { a[q4]=1; } for(i=0;i<7;i++) { printf("%d",a[i]); printf(" "); } } return 0; } |
| Solution | Vani | 1714. Мнемоника и палиндромы 2 | 8 июн 2012 12:42 | 2 |
|
| acepted | kostan3 | 1327. Предохранители | 7 июн 2012 23:36 | 1 |
изменил в коде одну букву и он прошёл кому нужен код kostan3@spaces.ru |
| C++ | Varun Sharma | 1100. Таблица результатов | 7 июн 2012 23:34 | 5 |
C++ Varun Sharma 19 апр 2009 09:20 Well, this one turned out to be easy. Luckily there is a function in the header algorithm (stable_sort) that sorts the objects on the basis of one of its contents ! and that's all was needed here ! Try to think how to solve it without any sorting!!! Re: C++ [MSU Detritus] freopen 30 июл 2010 11:27 without ANY sorting? How do you sort array without any sorting? Re: C++ Tvildiani Daviti[Tbilisi SU] 11 авг 2011 21:31 It is not necessary to sort array :) Just read input + :) #include <cstdio> #include <algorithm> using namespace std; struct node { int id; int solve; } a [10000000 + 10]; bool cmp (node p, node q) { if ( p.solve > q.solve ) return true; return false; } int main () { int n; scanf ("%d", &n); for ( int i = 0; i < n; i++ ) scanf ("%d %d", &a [i].id, &a [i].solve); stable_sort (a, a + n, cmp); for ( int i = 0; i < n; i++ ) printf ("%d %d\n", a [i].id, a [i].solve); return 0; } |
| What right answers? | Vitalik | 1431. Сертификаты | 7 июн 2012 18:31 | 4 |
My program is mistaken on 3 test!!! Give right answers on these tests and please help me to find a mistake! 1 test: 5 5 6 7 7 4 My answer: 4 2 test: 6 1 1 1 1 1 1 My answer: 3 3 test: 8 3 8 2 9 1 5 5 29 My answer: 6 4 test: 10 1 1 1 1 1 1 1 1 1 30 My answer: 6 5 test: 12 15 12 1 23 5 12 27 3 21 11 10 4 My answer: 9 6 test: 13 4 2 3 7 6 1 5 2 4 4 6 5 25 My answer: 8 7 test: 15 4 7 2 8 6 1 12 30 1 2 4 8 10 10 3 My answer: 9 8 test: 6 1 2 3 4 5 6 My answer: 5 9 test: 15 6 2 4 8 12 14 18 20 24 28 2 4 26 30 22 My answer: 10 10 test: 12 14 2 6 7 3 9 7 1 2 1 2 1 My answer: 8 In advance thanks!!! - 1. 3 - 2. 6 + 3. 6 - 4. 10 - 5. 10 + 6. 8 - 7. 11 - 8. 3 - 9. 15 + 10. 8 You have 30%. Work. >+ 10. 8 12 14 2 6 7 3 9 7 1 2 1 2 1 let's take 12 {10,4} 2 6 {5,2} 3 9 7 1 2 1 2 1 then we have seven pairs (is not true)?: (2,1) (2,1) (1,2) (6,7) (2,3) (4,5) (10,9) P.S. sorry for eng. and I got AC. Edited by author 14.06.2011 17:25 Edited by author 14.06.2011 17:25 "A hired designer reckons that all diplomas of the same kind (for example, for winning semifinals) must be in the same row" Doesn't that mean, that we can't separate 14 as 10 and 4? |
| [JAVA] Why is it CRASH ? :( | icytwister | 1083. Факториалы!!! | 7 июн 2012 13:04 | 2 |
import java.util.*; public class MyFact { int factorial(int n,int k) { int res; if(n==1) return 1; else if((n-1)%k!=0) return 1;
res=factorial(n-k,k)*n; return res;
}
public static void main(String [] args) { int fact=1;
MyFact f=new MyFact();
Scanner in=new Scanner(System.in); int n=in.nextInt();
int k=in.nextInt(); System.out.print(+f.factorial(n,k)); } } Edited by author 05.06.2012 18:20 Read the input data format carefully! An integer number "k" does not follow after integer number n. Input format example: 9 !! You should count number of exclamation marks (!). |
| Тут где ошибка помогите | Hamdam | 1209. 1, 10, 100, 1000... | 6 июн 2012 23:16 | 4 |
#include <iostream> using namespace std; int main () { unsigned int A[65536]; unsigned short int N,Y; cin>>N; for (int i=1; i<=N;i++) cin>>A[i]; for (int i=1;i<=N; i++) { int S=0,j=1; bool k=true; while (k) { S+=j; j++; if (A[i]<=S) k=false; } Y=S-A[i]; if (((j-1)-Y)==1) cout<<"1"<<" "; else cout<<"0"<<" "; } return 0; } Edited by author 06.06.2012 18:42 hi mister Hamdam your code has any mistake it's truely code is mine so you want to see it? please phone to me if you have any questions phone number: +998916378115 Ok!!! Let's take it!!! #include <iostream> #include <math.h> using namespace std; int main() { long float m,n; int N; cin>>N; for (int i=1; i<=N; i++) { cin>>m; n=(1+sqrt(8*m-7))/2; if((1+sqrt(8*m-7))/2==floor((1+sqrt(8*m-7))/2)) cout<<1<<" "; else cout<<0<<" "; } cin>>N; return 0; } Kottakon raxmat ! Edited by author 06.06.2012 23:17 |
| Hints please | galymzhan | 1019. Перекрашивание прямой | 6 июн 2012 14:32 | 1 |
Can someone give hints on how to approach this problem? What data structures do I need? I can't find out how to apply Interval tree. |
| what is Month tram ticket? | shafaet | 1085. Встреча | 5 июн 2012 16:40 | 2 |
what is Month tram ticket? This "month tram ticket" allows you to use tram as much times as you want without any payment. |
| In the sample checkers are located on the white cells | Alexey Dergunov [Samara SAU] | 1516. Ностальгия | 5 июн 2012 15:52 | 1 |
Why are checkers located on the white cells? According to the rules, they must be located on the black cells. |
| [JAVA] Where is my mistake? | icytwister | 1820. Уральские бифштексы | 5 июн 2012 14:44 | 4 |
import java.util.*; public class TimusUralBif { int n; int k; int clock; public static void main(String [] args) { TimusUralBif b=new TimusUralBif(); Scanner in=new Scanner(System.in); b.n=in.nextInt(); if(b.n<1 || b.n>1000) return;
b.k=in.nextInt(); if(b.k<1 || b.k>1000) return;
if(b.n%b.k==0) b.clock=((b.n/b.k)*2); else if(b.n/b.k==1) b.clock=b.n%b.k+2; else if(b.k>b.n) b.clock=2; else b.clock=b.n%b.k+2+(b.n/b.k);
System.out.print(+b.clock); } } Help me, please :( Edited by author 05.06.2012 18:21 Write your e-mail. I help you. ice.couples@gmail.com Neofit thank you Edited by author 05.06.2012 14:45 |
| Help me | MUZAFFAR | | 5 июн 2012 11:15 | 1 |
|
| Помогите плиз тест 4! | AndreyKopchuk | 1295. Бред | 4 июн 2012 20:07 | 2 |
В чём ошибка ни как разобраться не могу.
#include <conio.h> #include <stdio.h> #include <iostream> #include <fstream> using namespace std;
int step (int a , int b){ int cur , i; cur = 1; for (i = 0; i < b; i++){ cur = cur *a; } return cur; } int main(){ int n, c , i, p; cin >> n; p = 0; c = step(1,n) + step(2,n) + step(3,n) + step(4,n); for(p = 0; (c%10) == 0 ; c = c/10){ if(c%10 == 0){ p++; } } cout << p; return 0; } В зарание спасибо. дело в том, что числа слишком большие получаются представляете сколько будет 2^300000... вообще-то надо использовать то, что количество нулей изменяется циклично... |
| Тест 1 почему не работает ????!!! | AndreyKopchuk | 1638. Книжный червь | 4 июн 2012 19:01 | 3 |
Здравствуйте. Ни как не могу понять что тут не правильно. Помогите пожалуйста. #include <conio.h> #include <stdio.h> #include <iostream> #include <fstream> using namespace std;
int main(){ int p, a,b,c,d,i; long long cur; cin >>a; cin >>b; cin >>c; cin >>d; cur = 0; if ( d > c){ p = d - c+ 1; cur = a*p; cur = cur + b*(p*2 - 2); cout << cur; return 0; } if ( c < d){ p = c - d + 1; cur = b*(p*2 - 2); cur = cur + a * (p - 2); cout << cur; return 0; } } И почему в условном тесте ошибка? Там 22 должно быть а не 2. в тесте все правильно просто первая страница справа, а последняя слева... ну сами подумайте.. когда вы ставите книгу на полку корешком к себе, получается что она переворачивается :) Теперь понятно. Спасибо большое. Edited by author 04.06.2012 19:02 Edited by author 04.06.2012 19:02 |
| Crash (access violation) Test #7 | repy | 1880. Собственные числа Psych Up | 4 июн 2012 17:40 | 2 |
help please code: int main() { int n1,n2,n3,s; int k1[1000],k2[1000],k3[1000]; s=0; cin >> n1; for (int i=1;i<=n1;i++) cin >> k1[i]; cin >> n2; for (int i=1;i<=n2;i++) cin >> k2[i]; cin >> n3; for (int i=1;i<=n3;i++) cin >> k3[i]; for (int i=1;i<=n1;i++) for (int j=1;j<=n2;j++) if (k1[i]==k2[j]) { for (int z=1;z<=n3;z++) {if (k3[z]==k2[j]) {s++; break;} } break;} cout << s; } The number of eigen values might be up to 4000. So increase your array size from 1000 to 4000. |
| WA 4??? | scythe | 1323. Одноклассники | 4 июн 2012 02:56 | 1 |
|
| The statement is bad | Alexey Dergunov [Samara SAU] | 1346. Интервалы монотонности | 3 июн 2012 19:59 | 2 |
Function is not (strictly) increasing or decreasing, it is NON-DECREASING or NON-INCREASING. Test: 1 6 1 1 2 2 3 3 Answer: 1, not 4! |
| Why? | n3v3r_die | 1607. Такси | 3 июн 2012 15:42 | 2 |
Why? n3v3r_die 18 фев 2012 14:55 #include <iostream> using namespace std; int taxi(int a,int b,int c,int d){ if ((a+b)>c) {return c;} a+=b; if ((c-d)<a) return a; c-=d; taxi(a,b,c,d); } int main() { int a,b,c,d; cin>>a>>b>>c>>d; cout<<taxi(a,b,c,d); return 0; } Wrong answer test #1 Re: Why? Stefan Eniceicu 3 июн 2012 15:42 "<=" and ">=" in those ifs. there is one more case where a >= c where you need to return a. |
| Wrong sample or output format | Geno Roupsky | 1015. Найдите различия! | 3 июн 2012 08:05 | 5 |
The output format says: Print Q And then Print Q lines of the form NumSheme Count But the sample output is written 2 1 2 3 Why there isn't any '1' after the 3. And what does the sentence: 'Numbers in each line of the output must be sorted in increasing order' mean? How can you sort NumSheme and Count when it is said that they should be ano after another in a strict way? > The output format says: > Print Q > And then Print Q lines of the form > NumSheme Count > > But the sample output is written > 2 > 1 2 > 3 > Why there isn't any '1' after the 3. > > And what does the sentence: > 'Numbers in each line of the output must be sorted in > increasing order' mean? How can you sort NumSheme and Count > when it is said that they should be ano after another in a > strict way? The output is wrong - but not in the way you describe. All three die are different - note 1 dot opposite 2 dots, 3 dots and 4 dots for the three die respectively. The output should read: 3 1 2 3 This is the number of different die types followed by the die in each type in increasing order. > The output is wrong - but not in the way you describe. > > All three die are different - note 1 dot opposite 2 dots, 3 > dots and 4 dots for the three die respectively. > > The output should read: > 3 > 1 > 2 > 3 > > This is the number of different die types followed by the > die in each type in increasing order.
No, sample output is correct. Sample input is wrong. Fixed. 'Next Q lines should contain the numbers of dice with the same scheme. ' It is the numbers, not the count. |