Общий форумСтранно, но со struct работает и у меня; но не на сервере. У меня libc6. #include <stdio.h> #include <math.h> struct Node // РЕШЕНИЕ: ЗДЕСЬ НУЖНО ПИСАТЬ class. Компилятор тимуса ругается почему-то. { public: Node* prev; double info; }; int main() { Node* p = NULL; Node* node; double d; while(scanf("%lf",&d)!=EOF) { node = new Node; node->info = sqrt(d); node->prev = p; p = node; } while (p != NULL) { printf("%.4lf\n", p->info); p = p->prev; } return 0; } Edited by author 31.12.2009 03:44 Выводить надо в обратном порядке I have got AC for this problem but my solution is quite inefficient http://acm.timus.ru/status.aspx?space=1&num=1119&author=82952 It takes me 0.156 seconds to compute the answer, but there are many ppl who got solution in 0.015 secs.If possible please email me one of the efficient solution (C++ one).my email address is pjas002@aucklanduni.ac.nz Thanks Would anyone happen to know what test #12 is, or otherwise suggest something similar? Because I keep getting Time limit exceeded on it. Thanks in advance. Please give me some test or hint. Give me your mail, I'll try to help you) My mail: <deleted> Edited by author 29.11.2007 19:39 i ALSO GOT wA4. hELP Mistake because of wrong processing obstacles #include <stdio.h> #include <math.h> int main(){ freopen("b.in","r",stdin); freopen("b.out","w",stdout); double x[102],y[102]; double d1,d2; int i,star=0,k,m,n,j; double s,r,pi=2*acos(0); scanf("%d",&k); for(m=0;m<k;m++){ s=0; scanf("%d %Lf",&n,&r); for(i=0;i<n;i++) scanf("%Lf %Lf \n",&x[i],&y[i]); for(j=0;j<n-1;j++){ d1=abs(x[j]-x[j+1]); d2=abs(y[j]-y[j+1]); s=s+sqrt(d1*d1 + d2*d2); } d1=abs(x[0]-x[n-1]); d2=abs(y[0]-y[n-1]); s=s+sqrt(d1*d1 + d2*d2); s=s+(n*pi*r)/2; if(star==0) star=1; else printf("\n"); printf("%.2Lf",s); } return 0; } #include <iostream> #include <cmath> using namespace std; int main(){ double PI=acos(-1.0); int N; double r(0), perimeter(0); cin>>N>>r; double *pointx, *pointy; pointx = new double[N+1]; pointy = new double[N+1]; for(int a=0; a<N; a++){ cin>>pointx[a]>>pointy[a]; } pointy[N]= pointx[0]; pointx[N] = pointy[0]; cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); if(N==1){ perimeter=2*PI*r; cout<<perimeter;
} else{ if(N==2){ perimeter=2*(pow((pow((pointx[0]-pointx[1]),2)+pow((pointy[0]-pointy[1]),2)),0.5)) + 2*PI*r; cout<<perimeter;
} else{ double angle(0); for(int a=0; a<N; a++){ perimeter += pow((pow((pointx[a]-pointx[a+1]),2)+pow((pointy[a]-pointy[a+1]),2)),0.5); }
double p1x, p2x, p3x, p1y, p2y, p3y, m1, m2;
p1x=pointx[N-1]; p2x=pointx[0]; p3x=pointx[1]; p1y=pointy[N-1]; p2y=pointy[0]; p3y=pointy[1]; if(p3x==p2x) m1=tan(PI/2.0); if(p2x==p1x) m2=tan(PI/2.0); if(p2x!=p3x) m1=(p3y-p2y)/(p3x-p2x); if(p2x!=p1x) m2=(p1y-p2y)/(p1x-p2x); angle = 2*PI - (PI + fabs(atan(m1)-atan(m2))); for(int a=1; a<N; a++){ p1x=pointx[a-1]; p2x=pointx[a]; p3x=pointx[a+1]; p1y=pointy[a-1]; p2y=pointy[a]; p3y=pointy[a+1]; if(p3x==p2x) m1=tan(PI/2.0); if(p2x==p1x) m2=tan(PI/2.0); if(p2x!=p3x) m1=(p3y-p2y)/(p3x-p2x); if(p2x!=p1x) m2=(p1y-p2y)/(p1x-p2x);
angle += ((2*PI) - (PI + fabs(atan(m1)-atan(m2)))); }
perimeter += r*angle; cout<<perimeter; }} delete pointx; delete pointy; return 0;}
// even me wrong answer Edited by author 13.01.2010 20:27 Edited by author 13.01.2010 20:27 using System; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string razd=":;, -"; string kp=".!?"; string dig = "0123456789"; string[] input = Console.In.ReadLine().Split( new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); int cnt = 0; int ns = 0; int nb = 0; for (int i = 0; i < input.Length; i++) { string s = input[i]; for (int j = 0; j < s.Length; j++) { if ((s[j] >= 'A' && s[j] <= 'Z') || (s[j]>='a' && s[j]<='z') || dig.IndexOf(s[j])>=0) { nb++; if (ns == 0) ns++; if (nb == 1 && ns == 1 && (s[j] >= 'a' && s[j] <= 'z')) cnt++; if ((s[j] >= 'A' && s[j] <= 'Z') && nb > 1) cnt++; } if (razd.IndexOf(s[j]) >= 0) { nb=0; if (ns > 0) ns++; } if (kp.IndexOf(s[j])>=0) { ns = 0; nb = 0; } } nb = 0; } Console.WriteLine(cnt.ToString()); Console.ReadKey(); } } } i got wa in #10 too try this Asf,.,a the ans is 1 What the answer to test: m k n 12 3 2 18 I got 53 and WA I really don't like to do it, but i just can't find what is wrong in my code... In my pc it works pretty fine.. but, i got WA 4#... my bugged code: ========================================================== #include <iostream> using namespace std; void reordena(int *numeros[],int difzero,int num) { int rdn1,rdn2,aux; rdn1 = rand() % difzero; rdn2 = rand() % difzero; aux = numeros[num][rdn1]; numeros[num][rdn1] = numeros[num][rdn2]; numeros[num][rdn2] = aux; } void permuta(int *numeros[],int num,int tam) { int cont,cont2,aux,difzero=0,resp=0; int mult; long int contador=0; for(cont=0;cont<tam-1;cont++) { for(cont2=0;cont2<tam-1;cont2++) { if(numeros[num][cont2]==0) { aux = numeros[num][cont2]; numeros[num][cont2] = numeros[num][cont2+1]; numeros[num][cont2+1] = aux; } } } for(cont=0;cont<tam;cont++) { if(numeros[num][cont]!=0) difzero++; } mult=1; for(cont=difzero-1;cont>=0;cont--) { aux=(numeros[num][cont]*mult); resp+=aux; mult*=10; } while(resp%7!=0) { reordena(numeros,difzero,num); mult=1; resp=0; for(cont=difzero-1;cont>=0;cont--) { aux=(numeros[num][cont]*mult); resp+=aux; mult*=10; } contador++; if(contador>=1000000) { numeros[num][0]=0; resp=0; } } } int main() { int N,cont,**numeros,*tam; char aux[200]; cin >> N; if(N<0) exit(0); if(N>10000) exit(0); tam = new int[N]; numeros = new int*[N]; for(cont=0;cont<N;cont++) { numeros[cont] = new int[20]; } for(cont=0;cont<N;cont++) { cin >> aux; tam[cont] = strlen(aux); if(tam[cont]>20) { exit(0); } for(int cont2=0;cont2<tam[cont];cont2++) { numeros[cont][cont2]=aux[cont2]-'0'; } permuta(numeros,cont,tam[cont]); } system("cls"); for(cont=0;cont<N;cont++) { for(int cont2=0;cont2<tam[cont];cont2++) { if(numeros[cont][0]==0) { if(cont2==0) cout << "0"; } else if(numeros[cont][cont2]!=0) cout << numeros[cont][cont2]; } if(cont!=N-1) cout << endl; } delete [] numeros; delete [] tam; return 0; } ======================================================== please, help if you can =/ May be late=) but if input data contain 0 all zeroes must be output for example input: 1 12300134 example output: 13124300 May be anybody knows, what is specific of the second test? All my examples work correctly, but the second test...... }:-/ Many times my code was reviewed and rewatched, but still WA7. Could anybody help? What wrong with code? May be this algorithm gives not the optimal path? int main() { double r, a; std::cin >> r >> a; // first, walk to the edge of the island double s = r; // total angle of undiscovered edge const double a_left = 360.0 - 2.0*a; // hops count on 2*a "arc" line const int full_hops = (int)(a_left / (2.0*a)); s += range(r, to_rad(2.0*a)) * full_hops; // remaining angle to hop double a_rem = a_left - full_hops * (2.0 * a); s += range(r, to_rad(a_rem)); std::cout << std::fixed << std::setprecision(12) << s << std::endl; } Your algorithm allows me to AC. Maybe problem in calculations, in "to_rad" or "range"... I wrote to_rad and range to compile your code, and compared my code with yours: all output is identical. So, maybe you've mistook in one of these functions. Edited by author 18.10.2009 00:00 Thank you a lot for a great advice! Problem was eliminated after rewriting range() function: Old: used cosinus theorem New: using sinus to radius multiplication AC! Dmitriy S. Hodyrev! You solved 1726. If you read this, help me, please. My e-mail in my profile. Moders, sorry for the message concerning not this problem. But did you think about a functionality of allowing users to send private messages to the other users' e-mails through a web-form? I had the same problem: Since the cosine can be quite close to zero its square root is not calculated properly. So I also didn't use cosine theorem but calculated the length of the chords with simpler geometry: long double x = radius * cos(angle); long double y = radius * sin(angle); long double ans = sqrt((x - radius) * (x - radius) + y * y); Here the square root is done over the distance, not over the cosine, which, as it seems, solved the problem. Use the law of sines instead of cosines. я решаю через количество пересечений графиком синуса ось ох, вроде алгоритм правильный а преодолеть третий тест не могу. помогите пожалуйста!!! 1) если число k простое, то результат: k/2 2 пример: >31 15 2 2)если число k является степенью двойки, то результат: k 1 пример: >1024 1024 1 3)остальные числа перебором(перебирать а1-первый элемент арифметичиской прогрессии) и через квадратное уравнение находить p. P.S. AC 0.031 137 КБ Thank уравнение кому нужно (по крайней мере такое у меня) 0.5p^2+(a1-0.5)*p-n=0 если перебирать не a1, а p, то можно сэкономить время =) P.S. AC 0.015 118kb #include <iostream.h> long int fac(long int k) { int i,total=1; if(k==0) { return 1; } for(i=1;i<=k;i++) { total*=i; } return total; } int main() { long int n,total=0,i; cin>>n; { if(n<14) { for(i=2;i<=n;i++) { total+=fac(n)/fac(n-i); } cout<<total<<endl; } } if(n>14&&n<17) { for(i=2;i<=n;i++) { total+=fac(n)/fac(n-i); } cout<<total<<endl; } if(n==14) { cout<<"87178291200"<<endl; } if(n==17) { cout<<"355687428096000"<<endl; } if(n==18) { cout<<"6402373705728000"<<endl; } if(n==19) { cout<<"121645100408832000"<<endl; } if(n==20) { cout<<"2432902008176640000"<<endl; } if(n==21) { cout<<"51090942171709440000"<<endl; } return 0; } for example for 21 answer is 138879579704209680000 WHY?????????? If you have WA6 try this test: 40 5 12368145698754*11111*21*111*000010000000 ans = 34 This test helped me to pass Test 6, but then I got WA 10. Special thanks to <A HREF=" http://acm.timus.ru/author.aspx?id=69418">Bunyodbek Bobodjanov (TATU UF)</A>. This test was suggested by him but it was contained some mistake. Edited by author 08.01.2010 17:58Is it really appropriate to translate 'целые числа' as 'whole numbers'? short, int, long etc... ;) #include <cstdlib> #include <iostream> //----------Funkcje---------------------------- long long nwd(long long a, long long b) { if (b>=1) nwd(b, a%b); if (b=0) return a; } using namespace std; //---------------Program------------------------------------ int main(int argc, char *argv[]) { int n; long long tab[1002]={0}; //printf("Dla ilu liczb chcesz policzyc NWD?: \n"); scanf("%d", &n); //printf("Podaj liczby: \n"); for (int i=0;i<n;i++) scanf("%I64d", &tab[i]); long long wynik=tab[0]; for (int i=0;i<n-1;i++) { wynik=nwd(tab[i],tab[i+1]); tab[i+1]=wynik; }
//printf("NWD wynosi %I64d \n", wynik); printf("%I64d", wynik);
system("PAUSE"); return EXIT_SUCCESS; } use __int64 instead long long I insert to my array only the final verdict of author, then start to counting; if WA,ML,TL 7 min++,max++ if AC,WA,ML,TL 6 max++ print min,max Why WA13 Edited by author 19.10.2009 22:28 send your code to me ,I will look! Edited by author 19.10.2009 01:49 Edited by author 19.10.2009 19:52 Edited by author 19.10.2009 20:26 5 [SPbSU_ITMO]_WiNGeR TL 6 Milanin_(TNU) WA 6 Vladimir_Yakovlev_(USU) AC Sandro_(USU) ML 7 Sandro_(USU) WA 4 Think about it! I think the answer is 0 3 is it right? No,why do you think so? Edited by author 19.10.2009 23:50 i can't understand :( why the answer isn't '0 3'? My answer for this test is "1 4"...is it correct? I am also getting wrong answer on test 13. Thanks I got it eventually...I was just making a small mistake...saving those tests in my hashmap which was less than 6...hope that helps if (pts[m].y == (int)(Math.Round(k * (double)pts[m].x + b))) this i changed on if (Math.Abs(pts[m].y - (k * (double)pts[m].x + b))<0.000000001) and now I have AC Edited by author 08.01.2010 03:08 Please, gimme some tests equal test8 Edited by author 08.01.2010 02:59 |
|