Friday, June 10, 2011

11530 - SMS Typing


782 - Contour Painting


784 - Maze Exploration


785 - Grid Colouring


852 - Deciding victory in Go


Monday, June 6, 2011

10420 - List of Conquests


10363 - Tic Tac Toe


941 - Permutations


661 - Blowing Fuses


10683 - The decadary watch


11616 - Roman Numerals


11498 - Division of Nlogonia


377 - Cowculations


11223 - O: dah dah dah!


Sunday, June 5, 2011

394 - Mapmaker

#include<stdio.h>
#include<string.h>

char NAME[20][20];
int BA[20],W[20],D[30];
int DIM[20][40],Index,pos[30];

int calculate();

main()  {
  
    int i,j,k,name,test,lim;
    char ARRAY[15];
    //freopen("in.txt","r",stdin);
  
    scanf("%d%d", &name, &test);
  
    for(i = 0; i<name; i ++)
    {
        scanf("%s%d%d%d",NAME[i], &BA[i], &W[i], &D[i]);
        lim = D[i]<<1;;
        for(j = 0; j < lim; j ++)
            scanf("%d", &DIM[i][j]);
    }
  
    for(i = 0; i<test; i ++)
    {
        scanf("%s",ARRAY);
        for(j = 0; j<name;  j ++)
            if(!strcmp(ARRAY,NAME[j]))
                break;
        k = D[j];
        Index = j;
        for(j = 0; j<k; j ++)
            scanf("%d", &pos[j]);
        calculate();
    }
    return 0;
}

int calculate()
{
  
    int i,j,k,m,L[30],pos_1[20],lim;
    int address;
  
    k = D[Index];
    m = 0;
    lim = k<<1;
  
    for(j = 0; j<lim; j += 2)
    {
        pos_1[m] = pos[m] - DIM[Index][j];
        m ++;
    }
    m = 0;
    for(j = 0; j<lim; j += 2)
        L[m++] = DIM[Index][j+1] - DIM[Index][j] + 1;
  
    if(k == 1 )
        address = pos_1[0];
  
    else if( k == 2)
        address = pos_1[0] * L[1] + pos_1[1];
  
    else
    {
      
        address = L[1] * pos_1[0] + pos_1[1];
        for(i = 2; i<k; i ++)
            address = address * L[i] + pos_1[i];
    }
  
  
    address = W[Index] * address + BA[Index];
  
    printf("%s[",NAME[Index]);
    for(i = 0; i<k; i ++)
    {
        printf("%d",pos[i]);
        if(i < k-1)
            printf(", ");
    }
    printf("] = %d\n",address);
    return 0;
}

481 - What Goes Up


Friday, May 27, 2011

11110 - Equidivisions

#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>
#define M 103
using namespace std;

int Board[M][M],point[60];
int start[M][2],N,n;
char inp[10000];
int next[4][2]={{1,0},{-1,0},{0,1},{0,-1}};

void format (int num);
void DFS_Visit(int,int);

int main()
{
    int i,j,f;
    //freopen("in.txt","r",stdin);

    while(gets(inp))
    {
        sscanf(inp,"%d",&n);
        if(!n)break;

        for(i=0;i<=n;i++)
            for(j=0;j<=n;j++)
                Board[i][j] = n;

        for(i=1;i<n;i++)
        {
            gets(inp);
            format(i);
        }

        f = 1;
        for(i=0;i<n;i++)
            for(j=0;j<n;j++)
            {
                if(!Board[i][j])
                    continue;
                N=1;

                DFS_Visit(i,j);
                if(N!=n){f=0;goto NEXT;}
            }
NEXT:
        if(f)
            printf("good\n");
        else
            printf("wrong\n");

        memset(Board,0,sizeof(Board));
        memset(point,0,sizeof(point));
        memset(start,0,sizeof(start));
    }
    return 0;
}

void DFS_Visit(int u,int v)
{
    int i,tu,tv,x;
    x = Board[u][v];
    Board[u][v] = 0;

    for(i=0;i<4;i++)
    {
        tu = u + next[i][0];
        tv = v + next[i][1];
        if(tu>=0&&tu<n&&tv>=0&&tv<n&&Board[tu][tv]==x)
        {
            N++;
            DFS_Visit(tu,tv);
        }
    }
}

void format (int num)
{
    char *pch;
    pch = strtok (inp, " ");

    while ( pch != NULL )
    {
        int c1 = atoi (pch);
        pch = strtok (NULL, " ");
        int c2 = atoi (pch);
        pch = strtok (NULL, " ");
        Board [c1 - 1] [c2 - 1] = num;
    }
}

11710 - Expensive subway


12015 - Google is Feeling Lucky


Tuesday, May 3, 2011

10994 - Simple Addition


10991 - Region


10970 - Big Chocolate


10916 - Factstone Benchmark


10879 - Code Refactoring


10878 - Decode the tape


10812 - Beat the Spread!


10790 - How Many Points of Intersection?


10783 - Odd Sum


10696 - f91


10591 - Happy Number


10589 - Area


10579 - Fibonacci Numbers


10499 - The Land of Justice


10494 - If We Were a Child Again


10469 - To Carry or not to Carry


10451 - Ancient Village Sports


10432 - Polygon Inside A Circle


10394 - Twin Primes


10375 - Choose and divide


10370 - Above Average


10347 - Medians


10346 - Peter's Smokes


10340 - All in All


Thursday, March 17, 2011

10098 - Generating Fast


10282 - Babelfish


10079 - Pizza Cutting


10050 - Hartals


10041 - Vito's Family


10038 - Jolly Jumpers


10035 - Primary Arithmetic


10025 - The ? 1 ? 2 ? ... ? n = k problem


10019 - Funny Encryption Method


10018 - Reverse and Add


10014 - Simple calculations


10013 - Super long sums


10008 - What's Cryptanalysis?


10006 - Carmichael Numbers


694 - The Collatz Sequence


686 - Goldbach's Conjecture (II)


Sunday, February 27, 2011

673 - Parentheses Balance


640 - Self Numbers


623 - 500!


621 - Secret Research


591 - Box of Bricks


583 - Prime Factors


579 - ClockHands


575 - Skew Binary


573 - The Snail


568 - Just the Facts

543 - Goldbach's Conjecture

541 - Error Correction


530 - Binomial Showdown


499- What's The Frequency, Kenneth?


495 - Fibonacci Freeze


494 - Kindergarten Counting Game


490 - Rotating Sentences


489 - Hangman Judge


488 - Triangle Wave


484- The Department of Redundancy Department


483 - Word Scramble


476- Points in Figures: Rectangles


465 - Overflow


458 - The Decoder


424 - Integer Inquiry


414 - Machined Surfaces


412 - Pi


408 - Uniform Generator


406 - Prime Cuts


382 - Perfection


375- Inscribed Circles and Isosceles Triangles


374 - Big Mod


369 - Combinations


350 - Pseudo-Random Number


324 - Factorial Frequencies


299 - Train Swapping


294 - Divisors


272 - TEX Quotes


264 - Count on Cantor


256 - Quirksome Squares


160 - Factors and Factorials


146 - ID Codes


136 - Ugly Numbers


113 - Power of Cryptography


Friday, February 18, 2011

11879 - Multiple of 17


11878 - Homework Checker


11877 - The Coco-Cola Store


11854 - Egypt


11849 - CD


11805 - Bafana Bafana


11777 - Automate the Grades


11764 - Jumping Mario


11743 - Credit Check


11727 - Cost Cutting


11716 - Digital Fortress


11715 - Car


11713 - Abstract Names


11689 - Soda Surpler


11677 - Alarm Clock


11661 - Burger Time?


11614 - Etruscan Warriors Never Play Chess


11636 - Hello World!


11608 - No Problem


11577 - Letter Frequency


11462 - Age Sort


11417 - GCD


11408 - Count DePrimes


11388 - GCD LCM


11369 - Shopaholic


11332 - Summing Digits


11292 - Dragon of Loowater


11233 - Deli Deli


11185 - Ternary


11150 - Cola


11068 - An Easy Task


10948 - The primary problem


10940 - Throwing cards away II


10931 - Parity


10929 - You can say 11


10924 - Prime Words


10921 - Find the Telephone


10852 - Less Prime


10763 - Foreign Exchange


10699 - Count the factors


10678 - The Grazing Cow


10673 - Play with Floor and Ceiling


10533 - Digit Primes


10530 - Guessing Game


10450 - World Cup Noise


10424 - Love Calculator


10407 - Simple division


10324 - Zeros and Ones


10295 - Hay Points


10235 - Simply Emirp


10200 - Prime Time


10193 - All You Need Is Love


Wednesday, February 9, 2011

10137 - The Trip


10127 - Ones


10107 - What is the Median?


10104 - Euclid Problem


10070 - Leap Year or Not Leap Year and …


913 - Joana and the Odd Numbers


727 - Equation


644 - Immediate Decodability


594 - One Little, Two Little, Three Little Endians


401 - Palindromes


382 - Perfection


263-Number Chains