2012/4/17

Google Code Jam 2012 資格賽 第二題 Problem B. Dancing With the Googlers

Smail Set 一次 10分。

Large Set 一次 15分。

花費時間: 1hr 15min

 

http://code.google.com/codejam/contest/1460488/dashboard#s=p1&a=1

 

 

題目分析:

這一題在考題目理解能力,有人說數學的符號很重要,沒萊布尼茲發明微積分符號,

就沒有後來蓬勃的發展,那解程式符號與圖型也很重要,不然題目落落長,看了三遍也不懂。

 

看似很複雜,其實整體只有六種一般狀況加上一種例外。

六種一般狀況用表格表式,因為狀況單純所以用查表的,

就是table的第一與第二個column

 

 

 

From:

 

// DancingWithGooglers.cpp : Defines the entry point for the console application.

//

 

#include "stdafx.h"

 

void main()

{

        // 0=>x, 1=>sprz, 2=>count++

        int table[3][4] =

        {

                {0, 1, 0, 0},

                {0, 2, 0, 0},

                {0, 2, 1, 0}

        };

 

        int line,n,s,p,i,j,t,m,q,r,x;

        int count;

        scanf("%d", &line);

        for(i=0;i<line;i++)

        {

                count=0;

                scanf("%d %d %d", &n, &s, &p);

                for(j=0;j<n;j++)

                {

                        scanf("%d", &t);

                        if(t==0) //例外

                        {

                                if(p==0) count++;

                                continue;

                        }

                        m=t/3;

                        x = p-m;

                        if( x > 2 ) continue;

                        q = t-m*3;

 

                        //printf("n,s,p,t,m=t/3,x=p-m,q,table[q][x]=%d,%d,%d,%d,%d,%d,%d,%d\n",n,s,p,t,m,x,q,table[q][x]);

                        if(x>0)

                        {

                                r = table[q][x];

                                if(r==1) { //sprz

                                        if(s>0) {

                                                count ++;

                                                s--;

                                        }

                                }

                                if(r==2)

                                {

                                        count ++;

                                        //count += !(table[q][x]==0);

                                }

                        }else{

                                count++;                 

                        }

                }

                printf("Case #%d: %d\n", i+1,count);

        }      

}

2012/4/16

補鈣800D(維他命D3+鈣)


Vitamin D3 800 I.U. Calcium Carbonate (
600mg

碳酸鈣)


Google Code Jam 2012 資格賽 第三題 Problem C. RecycledNumbers

Smail Set 一次 10分。

Large Set 兩次 0分。

 

// RecycledNumbers.cpp : Defines the entry point for the console application.

//

#include "stdafx.h"

#include "string.h"

 

void main()

{     

        int line, len, i, n, k, x, A, B, m, head, tail, pow, pow2, ans, cnt, dup;      

        char str[8];

 

        scanf("%d\n\r", &line);   

        for(i=0;i<line;i++) {         

                scanf("%d %d", &A, &B);              

                ans=0;             

                for(n=A;n<=B;n++)

                {     

                        //printf("%d => ", n);

                        sprintf(str,"%d",n);

                        len = strlen(str);                       

                        tail = n;

                        pow = 1;

                        pow2 = 1;

                        for(x = 0; x<len; x++) {

                                pow2 *= 10;

                        }     

                        cnt = 0;

                        dup = 1;

                        if( len == 4 && (n%100 == n/100) ) {

                                dup=2;

                        }

                        if( len == 6 && (n%1000 == n/1000) ) {

                                dup=2;

                        }

                        if( len == 6 && (n%100 == (n/100)%100) && (n%100 == (n/10000))) {

                                dup=3;

                        }

                        for(k=1;k<len;k++) {

                                tail /= 10;

                                pow *= 10;                             

                                pow2 /= 10;

                                head = (n % pow)*pow2;

                                m = head + tail;

                                if( A<=n && n<m && m<=B ) {

                                        //printf("%d ",m);

                                        cnt++;

                                }                                     

                        }     

                        ans += cnt/dup;

                        //printf("\n");

                }

                printf("Case #%d: ", i+1);

                printf("%d\n", ans);

        }             

}

Google Code Jam 2012 資格賽 第一題 Problem A. Speaking in Tongues

#include "stdafx.h"
#include "string.h"

int main(int argc, char* argv[])
{
char map[] = "yhesocvxduiglbkrztnwjpfmaq";
int line, i;
char c;

scanf("%d\n\r", &line);
for(i=0;i<line;i++) {
printf("Case #%d: ", i+1);
while(scanf("%c",&c) == 1 && c != '\n')
{
printf("%c",c==' '?' ':map[c-'a']);
}
printf("\n");
}
return 0;
}

2012/4/11

MOD已經擺脫過去負面形像了!

中時電子報:媒體收視滿意度MOD追上  http://news.chinatimes.com/tech/11050904/122012041000382.html

可見MOD已經擺脫過去負面形像了!

目前由於新、舊平台轉換青黃不接,新、舊平台服務差異:新平台目前暫未提供VOD18+、歡唱坊(無麥克風插孔)、金融理財(無金融卡插槽) 服務及台互、靖天SVOD服務,預計5月份可陸續推出服務。