ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1209. 1, 10, 100, 1000...

WA Please give me the Test#6
Posted by Luciano 17 Sep 2015 20:13
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
Posted by Pranta 10 Jun 2016 05:19
i am also getting WA at 5