|
|
вернуться в форумWA Please give me the Test#6 What is wrong #include <cstdio> unsigned long int contador[65535]; void carga() { for(int i=0;i<65535;i++) { if(i==0) contador[i] = 1; else contador[i] = contador[i-1] + i; }} bool busqueda(unsigned long int k[], int i) { bool buscador = false; int inf = 0, sup = 65534, centro; while(inf <= sup) { centro = ((sup - inf) / 2) + inf; if(contador[centro] == k[i]) { buscador = true; break; } if(contador[centro] < k[i]) { inf = centro + 1; } if(contador[centro] > k[i]) { sup = centro - 1; }} return buscador; } int main() { carga(); unsigned long int k[65535]; int n, i; scanf("%d", &n); for(int i=0;i<n;i++) { scanf("%lud", &k[i]); } for(i=0;i<n-1;i++) { if(busqueda(k, i)) printf("1 "); else printf("0 "); } if(busqueda(k, i)) printf("1"); else printf("0"); printf("\n"); } Re: WA Please give me the Test#6 Послано Pranta 10 июн 2016 05:19 i am also getting WA at 5 |
|
|