2010年9月26日 星期日

ACM 442 - Matrix Chain Multiplication

#include <stdio.h>
#include <ctype.h>

struct matrix
{
char ch;
int row;
int col;
int count;
};
struct matrix m[26], stack[200];

int main()
{
int n, row, col, i;
char ch, str[200];
scanf("%d", &n);
getchar();
for (i = 0; i < n; i ++)
{
scanf("%c %d %d", &ch, &row, &col);
getchar();
int index = ch - 'A';
m[index].ch = ch, m[index].row = row, m[index].col = col;
}
while (gets(str))
{
int count = 0, error = 0, index = 0;
int row = 0, col = 0;
for (i = 0; (ch = str[i]); i ++)
{
if (ch == '(') stack[index ++].ch = ch;
if (isupper(ch))
{
int s = ch - 'A';
row = m[s].row, col = m[s].col;
if (isupper(stack[index - 1].ch))
{
if (stack[index - 1].col != row)
{ error = 1; break; }
stack[index - 1].count += stack[index - 1].row * row * col;
stack[index - 1].col = col;
}
else
{
stack[index].ch = ch;
stack[index].row = row;
stack[index].col = col;
stack[index].count = 0;
index ++;
}
}
if (ch == ')')
{
if (index - 1 < 0) { error = 1; break; }
if (stack[index - 1].ch == '(') index --;
if (index - 2 >= 0 &&
isupper(stack[index - 1].ch) && stack[index - 2].ch == '(')
{
stack[index - 2].ch = stack[index - 1].ch;
stack[index - 2].row = stack[index - 1].row;
stack[index - 2].col = stack[index - 1].col;
stack[index - 2].count = stack[index - 1].count;
index --;
if (isupper(stack[index - 2].ch))
{
row = stack[index - 1].row;
col = stack[index - 1].col;
count = stack[index - 1].count;

if (stack[index - 2].col != row)
{ error = 1; break; }
stack[index - 2].count += (count + stack[index - 2].row * row * col);
stack[index - 2].col = col;
index --;
}
}
}

}

if (error == 0) printf("%d\n", stack[0].count);
else if (error) printf("error\n");

}
return 0;
}

回目錄
回首頁

ACM 424 - Integer Inquiry

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

#define NUMLEN 200

struct AddNum
{
int num[NUMLEN];
int length;
};

struct AddNum AN1, AN2;
char numStr[101];

int main()
{
int i, j;
while (gets(numStr))
{
if (numStr[0] == '0') break;
AN2.length = strlen(numStr) - 1;
for (i = AN2.length, j = 0; i >= 0; i --, j ++)
AN2.num[j] = numStr[i] - '0';
for (i = 0; i < NUMLEN; i ++)
{
AN1.num[i] += AN2.num[i];
if (AN1.num[i] >= 10)
AN1.num[i + 1] ++, AN1.num[i] %= 10;
}
}
for (i = NUMLEN - 1; ; i --)
if (AN1.num[i] > 0)
break;
for (; i >= 0; i --)
printf("%d", AN1.num[i]);
printf("\n");
return 0;
}

回目錄
回首頁

ACM 375 - Inscribed Circles and Isosceles Triangles

#include <stdio.h>
#include <math.h>
double B, H, SL, S, area, r, HSub2R, cycleLen;

int main()
{
double PI = 2*acos(0.0);
int n, i;
scanf("%d", &n);
for (i = 0; i < n; i ++)
{
cycleLen = 1e-12;
scanf("%lf %lf", &B, &H);
B += 1e-15; H += 1e-15;
SL = (double)sqrt( (H*H) + (B*B/4) );
area = B * H / 2;
r = 2 * area / (SL+SL+B);
while (r >= 0.000001)
{
cycleLen += 2 * r * PI;
HSub2R = H - 2 * r;
r *= HSub2R / H;
H = HSub2R;
}
if (i != 0) printf("\n");
printf("%13.6lf\n", cycleLen);
}
return 0;
}

回目錄
回首頁

ACM 374 - Big Mod

#include <stdio.h>
int f(int m,int n, int mod)
{
long long int mul = m;
long long int r = 1;
while(n){
if(n % 2 == 1){r *= mul;r %= mod;}
mul *= mul;
mul %= mod;
n >>= 1;
}
return r;
}
int main()
{
int B,P,M;
while(scanf("%d%d%d",&B,&P,&M)==3)
printf("%d\n",f(B,P,M));
return 0;
}

回目錄
回首頁

ACM 344 - Roman Digititis

#include <stdio.h>

struct RomanNum
{
int i;
int v;
int x;
int l;
int c;
};

struct RomanNum RN[101];

void adder(int index, int n)
{
if (n == 0) return;
if (n >= 40 && n <= 49)
RN[index].l ++, RN[index].x ++, n -= 40;
if (n >= 90 && n <= 99)
RN[index].c ++, RN[index].x ++, n -= 90;
if (n % 10 == 4)
RN[index].v ++, RN[index].i ++, n -= 4;
if (n % 10 == 9)
RN[index].x ++, RN[index].i ++, n -= 9;
if (n / 100 > 0)
RN[index].c += (n/100), n %= 100;
if (n / 50 > 0)
RN[index].l += (n/50), n %= 50;
if (n / 10 > 0)
RN[index].x += (n/10), n %= 10;
if (n / 5 > 0)
RN[index].v += (n/5), n %= 5;
if (n / 1 > 0)
RN[index].i += (n/1), n %= 1;
}

int main()
{
int i, n;
for (i = 0; i < 100; i ++)
{
adder(i, i + 1);
RN[i + 1].i = RN[i].i, RN[i + 1].v = RN[i].v, RN[i + 1].x = RN[i].x;
RN[i + 1].l = RN[i].l, RN[i + 1].c = RN[i].c;
}

while (1)
{
scanf("%d", &n);
if (n == 0) break;
n -= 1;
printf("%d: %d i, %d v, %d x, %d l, %d c\n", n+1, RN[n].i, RN[n].v, RN[n].x, RN[n].l, RN[n].c);
}
return 0;
}

回目錄
回首頁

2010年9月23日 星期四

DateTable 的 Top n 取得

常都是寫一段 SQL 語法後執行才能將所查詢的資料的 Top N 取出,可是如果還想再用這些原始資料做別的事情,就要用另外一種方法取出。用以下 C# 程式碼,能將 DataTable 的 Top N 取出。
DataTable DataTableTopN(DataTable dt, int rowCount)
{
DataTable dtn = dt.Clone();
for (int i = 0; i < rowCount; i++)
{
dtn.ImportRow(dt.Rows[i]);
}
return dtn;
}


回目錄
回首頁

2010年9月19日 星期日

ACM 340 - Master-Mind Hints

#include <stdio.h>

struct Ans
{
int ansInt;
int isComp;
};

int main()
{
int n, i, m, isZero, A, B, j, index = 0;
while (scanf("%d", &n) == 1)
{
if (n == 0) break;
printf("Game %d:\n", ++ index);
struct Ans a[n];
for (i = 0; i < n; i ++)
{
scanf("%d", &m);
a[i].ansInt = m;
a[i].isComp = 0;
}
struct Ans b[n];
while (1)
{
isZero = 1, A = 0, B = 0;
for (i = 0; i < n; i ++)
{
scanf("%d", &m);
if (m != 0) isZero = 0;
b[i].ansInt = m;
b[i].isComp = 0;
a[i].isComp = 0;
}
for (i = 0; i < n; i ++)
if (a[i].ansInt == b[i].ansInt)
A ++, a[i].isComp = 1, b[i].isComp = 1;
for (i = 0; i < n; i ++)
for (j = 0; j < n; j ++)
{
if (i != j && a[i].isComp == 0 && b[j].isComp == 0 && a[i].ansInt == b[j].ansInt)
B ++, a[i].isComp = 1, b[j].isComp = 1;
}
if (isZero) break;
else printf(" (%d,%d)\n", A, B);
}

}
return 0;
}

回目錄
回首頁

ACM 350 - Pseudo-Random Numbers

#include <stdio.h>

int PseRand(int Z, int I, int M, int L)
{
return (Z * L + I) % M;
}

int main()
{
int Z, I, M, L, caseNum = 1;

while (1)
{
scanf("%d %d %d %d", &Z, &I, &M, &L);
if (Z == 0 && I == 0 && M == 0 && L == 0) break;
int isTrue[10000] = {0}, len[10000] ;
printf("Case %d: ", caseNum++);
int count = 0;
while (!isTrue[L])
{
isTrue[L] = 1, len[L] = count ++;
L = PseRand(Z, I, M, L);
}
printf("%d\n", count - len[L]);
}

return 0;
}

回目錄
回首頁

ACM 299 - Train Swapping

#include <stdio.h>
#include <malloc.h>
int *S, size;

int bubbleSort ()
{
int i, j, tmp, count = 0;
for (i = 0; i < size; i ++)
{
for (j = 0; j < size - i - 1; j ++)
{
if (S[j] > S[j + 1])
{
tmp = S[j];
S[j] = S[j + 1];
S[j + 1] = tmp;
count ++;
}
}
}
return count;
}

int main()
{
/*freopen("111.txt", "r", stdin);
freopen("111w.txt", "w", stdout);*/
int n, i, j;
scanf("%d", &n);
for (i = 0; i < n; i ++)
{
scanf("%d", &size);

S = (int *)malloc(sizeof(int)*size);
for (j = 0; j < size; j ++)
scanf("%d", &S[j]);
printf("Optimal train swapping takes %d swaps.\n", bubbleSort());
free(S);
}
}

回目錄
回首頁

2010年9月18日 星期六

ACM 333 - Recognizing Good ISBNs

#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main()
{
char str[82];
int i, numCount, s, e;
while (gets(str))
{
if (strlen(str) == 0) { printf(" is incorrect.\n"); continue; }
numCount = 0;
int per = 0;
int tsum = 0;
int sum[9] = {0}, wrong = 0, d = 0, isX = 0, g = 0;
for (s = 0; str[s] == ' ' || str[s] == '\t' || isalpha(str[s]) ; s ++)
if (str[s] == 'X') break;
for (e = strlen(str) - 1; str[e] == ' ' || str[e] == '\t' || isalpha(str[e]); e --)
if (str[e] == 'X') break;
for (i = s; i <= e; i ++)
{
if (str[i] == '-') continue;
else if (isdigit(str[i]))
{
numCount ++;
per += str[i] - '0';
tsum += per;
}
else if (str[i] == 'X')
{
if (numCount != 9) { wrong = 1; break;}
else
{
per += 10;
tsum += per;
numCount ++;
}
}
else { wrong = 1; break;}
}
for (i = 0; str[i] == ' ' || str[i] == '\t'; i ++) ;
s = i;
for (i = strlen(str) - 1; str[i] == ' ' || str[i] == '\t'; i --) ;
e = i;
for (i = s; i <= e; i ++)
putchar(str[i]);
if (wrong) printf(" is incorrect.\n");
else if (numCount >= 10 && tsum % 11 == 0) printf(" is correct.\n");
else printf(" is incorrect.\n");

}
return 0;
}

回目錄
回首頁

ACM 332 - Rational Numbers from Repeating Fractions

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

int gcd(int a,int b)
{
if (a % b == 0){ return b;}
return gcd(b , a % b);
}

int pow10(int n)
{
int i, sum = 1;
for (i = 0; i < n; i ++)
sum *= 10;
return sum;
}

char str[20];

int main()
{
int j, i, k, h, g, d, s, caseNum = 1;
while(scanf("%d", &j) == 1 && j != -1)
{
scanf("%s", str);
char ch;
int len = strlen(str);
if (j != 0) d = pow10(len - 2) - pow10(len - 2 - j);
else d = pow10(len - 2);
k = 0, h = 0;
for (i = 2, g = 0; i < len; i ++, g ++)
{
ch = str[i];
if (g < (len - 2 - j)) h = h * 10 + (ch - '0');
k = k * 10 + (ch - '0');
}
if (j != 0)
{
s = gcd(k - h, d);
printf("Case %d: %d/%d\n", caseNum ++, (k - h) / s, d / s);
}
else
{
s = gcd(k, d);
printf("Case %d: %d/%d\n", caseNum ++, k / s, d / s);
}


}

return 0;
}

回目錄
回首頁

ACM 326 - Extrapolation Using a Difference Table

#include <stdio.h>

int a[50];

int main() {
int n, i, j, k;
scanf("%d", &n);
while (n)
{
for (i=0; i<n; i++)
scanf("%d", &a[i]);
scanf("%d", &k);
for (j=n-1; j>0; j--)
for (i=0; i<j; i++)
a[i] = a[i+1] - a[i];
for (i=0; i<k; i++)
for (j=1; j<n; j++)
a[j] += a[j-1];
printf("Term %d of the sequence is %d\n", n+k, a[n-1]);
scanf("%d", &n);
}
return 0;
}

回目錄
回首頁

ACM 311 - Packets

#include <stdio.h>

int residual[6], packets[6];

int main()
{
while (1)
{
int i, isZero = 1, total = 0;
for (i = 0; i < 6; i ++)
{
scanf("%d", &packets[i]);
residual[i] = 0;
if (packets[i] != 0)
isZero = 0;
}
if (isZero) break;
total += packets[5]; /* 6*6一人一個盒子 */
total += packets[4]; /* 5*5一人一個盒子,剩餘 11 個 1*1 空間 */
residual[0] += packets[4] * 11;
total += packets[3]; /* 4*4一人一個盒子,剩餘 5 個 2*2 空間 */
residual[1] += packets[3] * 5;

total += packets[2] / 4; /* 3*3 之處理方式 */
packets[2] %= 4, residual[2] = packets[2];
if (residual[2] == 1)
residual[2] = 0, residual[0] += 7, residual[1] += 5, total ++;
else if (residual[2] == 2)
residual[2] = 0, residual[0] += 6, residual[1] += 3, total ++;
else if (residual[2] == 3)
residual[2] = 0, residual[0] += 5, residual[1] += 1, total ++;

if (residual[1] >= packets[1]) /* 2*2 之處理方式 */
residual[1] -= packets[1], packets[1] = 0;
else
packets[1] -= residual[1], residual[1] = 0;
total += packets[1] / 9;
packets[1] %= 9;
if (packets[1] > 0)
residual[0] += 36 - packets[1] * 4, packets[1] = 0, total ++;
else residual[0] += residual[1] * 4, residual[1] = 0;

if (residual[0] >= packets[0]) /* 1*1 之處理方式 */
residual[0] -= packets[0], packets[0] = 0;
else
packets[0] -= residual[0], residual[0] = 0;
total += packets[0] / 36;
packets[0] %= 36;
if (packets[0] > 0)
total ++;
printf("%d\n", total);
}
return 0;
}

回目錄
回首頁

ACM 300 - Maya Calendar

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

char hMonthStr[19][8] = {"pop", "no", "zip", "zotz",
"tzec", "xul", "yoxkin", "mol",
"chen", "yax", "zac", "ceh",
"mac", "kankin", "muan", "pax",
"koyab", "cumhu", "uayet"};
char tMonthStr[20][10] = {"imix", "ik", "akbal", "kan",
"chicchan", "cimi", "manik", "lamat",
"muluk", "ok", "chuen", "eb",
"ben", "ix", "mem", "cib",
"caban", "eznab", "canac", "ahau"};
char dStr[6], mStr[8];
int main()
{
int hDay, hMonth, hYear, tDay, tMonth, tYear;
int n, days, i;
scanf("%d", &n);
printf("%d\n", n);
while (n --)
{
char *d;
scanf("%s %s %d", dStr, mStr, &hYear);
d = strtok(dStr, ".");
sscanf(d, "%d", &hDay);
for (i = 0; i < 19; i ++)
{
if (strcmp(hMonthStr[i], mStr) == 0)
{ hMonth = i; break; }
}
days = hDay + hMonth * 20 + hYear * 365;
tYear = days / 260;
days %= 260;
tMonth = days % 20;
tDay = days % 13 + 1;

printf("%d %s %d\n", tDay, tMonthStr[tMonth], tYear);
}
return 0;
}

回目錄
回首頁

ACM 272 - TEX Quotes

#include <stdio.h>

int main()
{
int style = 0;
char c;
while (1){
c = getchar();
if (c == EOF) break;
if (c == '\"')
{
if (style == 0)
{
printf("``");
style = 1;
}
else
{
printf("''");
style = 0;
}
}
else putchar(c);
}
return 0;
}

回目錄
回首頁

ACM 264 - Count on Cantor

#include<stdio.h>    
#include<stdlib.h>
#include<string.h>
#include<math.h>
main()
{
int n,a,b,c,d;
while(scanf("%d",&n)==1)
{
for(d=1,c=n;c>d;d++) c=c-d;
if ( d%2==1 ) a=d-c+1;
else a=c;
b=d+1-a;
printf("TERM %d IS %d/%d\n",n,a,b);
}
return 0;
}
以上程式轉自:http://mypaper.pchome.com.tw/iustlovefish/post/1311842753
稍微說明一下程式碼,先看以下圖形:標紅色部分,依照每斜行遞增,所以 d=1, c=n 初始化後,用一迴圈每做一次 c 減掉 d 而做完後 d 累加一,所以這一部份是做算出 n 是在第 d 斜行的第 c 個位置。
而這個圖表有一個特性,請看以下表:
x - 1 / y - 1x - 1 / yx - 1 / y + 1
x / y - 1x / yx / y + 1
x + 1 / y - 1x + 1 / yx + 1 / y + 1
只要 d 在奇數它是往左下走,偶數則往右上走,而只要 d 在奇數則該斜行的第一個位置為 1 / d,偶數為 d / 1,最後再依照它的位置算出正確答案。

此提與 ACM 10182 Bee Maja 頗像,我是用圖法煉鋼的方法寫出,但似乎比上面的程式碼還慢,所以還是參考他的做法。

回目錄
回首頁

ACM 256 - Quirksome Squares

#include <stdio.h>

int main( void )
{
int i, n, j;
while (1)
{
if (scanf("%d", &n) < 1) break;
if (n == 2)
{
for (i = 0; i < 10; i ++)
for (j = 0; j < 10; j ++)
{
if ( i + j >= 10) break;
if ((i + j)*(i + j) == (i*10 + j))
printf("%02d\n",(i*10 + j));
}
}
if (n == 4)
{
for (i = 0; i < 100; i ++)
for (j = 0; j < 100; j ++)
{
if ( i + j >= 100) break;
if ((i + j)*(i + j) == (i*100 + j))
printf("%04d\n",(i*100 + j));
}
}
if (n == 6)
{
for (i = 0; i < 1000; i ++)
for (j = 0; j < 1000; j ++)
{
if ( i + j >= 1000) break;
if ((i + j)*(i + j) == (i*1000 + j))
printf("%06d\n",(i*1000 + j));
}
}
if (n == 8)
{
for (i = 0; i < 10000; i ++)
for (j = 0; j < 10000; j ++)
{
if ( i + j >= 10000) break;
if ((i + j)*(i + j) == (i*10000 + j))
printf("%08d\n",(i*10000 + j));
}
}
}
return 0;
}

回目錄
回首頁

ACM 253 - Cube painting

#include <stdio.h>

char str[15] = {"\0"};
struct Cube
{
char ch1;
char ch2;
int isComp;
};

struct Cube c[6];

int main()
{
while (gets(str))
{
int isTurn = 0, i, j;
c[0].ch1 = str[0], c[0].ch2 = str[5], c[0].isComp = 0;
c[1].ch1 = str[1], c[1].ch2 = str[4], c[1].isComp = 0;
c[2].ch1 = str[2], c[2].ch2 = str[3], c[2].isComp = 0;
c[3].ch1 = str[6], c[3].ch2 = str[11], c[3].isComp = 0;
c[4].ch1 = str[7], c[4].ch2 = str[10], c[4].isComp = 0;
c[5].ch1 = str[8], c[5].ch2 = str[9], c[5].isComp = 0;
for (i = 0; i < 3; i ++)
for (j = 3; j < 6; j ++)
{
if (c[i].isComp == 0 && c[j].isComp == 0)
{
if (c[i].ch1 == c[j].ch1 && c[i].ch2 == c[j].ch2 ||
c[i].ch1 == c[j].ch2 && c[i].ch2 == c[j].ch1)
{
c[i].isComp = 1, c[j].isComp = 1;
break;
}
}
}
for (i = 0; i < 6; i ++)
if (c[i].isComp == 0)
isTurn = 1;
if (isTurn)
printf("FALSE\n");
else printf("TRUE\n");
}
return 0;
}

回目錄
回首頁

2010年9月17日 星期五

ACM 202 - Repeating Decimals

#include <stdio.h>
#include <memory.h>

#define MAX 5000
#define DISPLAY_LIMIT 50
#define MAX_INT 3000

int min (int a , int b){
return a > b ? b : a;
}


int main()
{
int digits[MAX + 1], remainderExist[MAX_INT], remainderPos[MAX_INT];
while (1)
{
int numerator, denominator, oNumerator, quotient, remainder, recode, i;

if (scanf("%d", &numerator) < 1) break;
oNumerator = numerator;
scanf("%d", &denominator);

memset (remainderExist, 0, sizeof(remainderExist));
memset (remainderPos, 0, sizeof(remainderPos));

quotient = numerator / denominator;
remainder = numerator % denominator;

recode = quotient;
int n = 0, isCycle = 0, cyclePos = MAX, cycleLen = 0;

while ( n <= MAX && !isCycle)
{
if (remainderExist[remainder] )
{
cyclePos = remainderPos[remainder];
cycleLen = n - cyclePos;
isCycle = 1;
}
else
{
remainderExist[remainder] = 1;
remainderPos[remainder] = n;
}
numerator = remainder * 10;

quotient = numerator / denominator;
remainder = numerator % denominator;
digits[n] = quotient;
n ++;
}
printf("%d/%d = %d.", oNumerator, denominator, recode);
int limit = min(cyclePos, DISPLAY_LIMIT);

for (i = 0; i < limit; ++i )
printf("%d", digits[i]);

if (cyclePos < DISPLAY_LIMIT)
{
printf("(");
limit = min(n - 1, DISPLAY_LIMIT);
for (i = cyclePos; i < limit; ++i )
printf("%d", digits[i]);
if (n > DISPLAY_LIMIT)
printf("...");
printf(")");
}
printf("\n");
printf(" %d = number of digits in repeating cycle\n\n",cycleLen );

}
return 0;
}

回目錄
回首頁

HTML 程式設計筆記目錄

  1. float 蓋到另一區塊 ( div ) 的解決方法
  2. javascript 取得參數值
  3. javascript 子視窗關閉,重新整理母視窗
  4. 跑馬燈(marquee)使用方法
  5. javascript 取得參數 key 和 value 轉存陣列
  6. Javascript UrlEncode、UrlDecode、SetCookie、GetCookie、DelCookie 的函數
  7. AJAX學習筆記
  8. jquery ui for bootstrap 的使用
  9. Jquery 子母頁面間的 json 參數傳遞



float 蓋到另一區塊 ( div ) 的解決方法

些時候,寫 html 語法時會碰到需要用 float 屬性調整格式,但 float 屬性會蓋到其他區塊,例如:div、pre、.....等等。此時,就需要利用到 clear 屬性幫你解決覆蓋到其他區塊使用 float 的元素。

float 屬性中,left 使元素浮動在左,而 right 使元素浮動在右,none 則不會有任何效果。

clear 屬性中,left 會解除左側元素的浮動,right 會解除右側元素的浮動,both 會解除兩側元素的浮動,none 則不會有任何效果。

ACM 11799 - Horror Dash

#include <stdio.h>

int getInt()
{
char ch;
int n = 0;
while( ch = getchar())
if(ch != ' ' && ch != '\n') break;
n = ch - 48;
while( ch = getchar())
{
if(ch == ' ' || ch == '\n') break;
n = n * 10 + ch - 48;
}
return n;
}

int main()
{
int caseNum, i, n, m, max, j;
caseNum = getInt();

for (i = 1; i <= caseNum; i ++)
{
n = getInt();
max = 0;
while (n --)
{
m = getInt();
if (m > max) max = m;
}
printf("Case %d: %d\n", i, max);
}
return 0;
}


回目錄
回首頁

ACM 11805 - Bafana Bafana

#include <stdio.h>

int getInt()
{
char ch;
int n = 0;
while( ch = getchar())
if(ch != ' ' && ch != '\n') break;
n = ch - 48;
while( ch = getchar())
{
if(ch == ' ' || ch == '\n') break;
n = n * 10 + ch - 48;
}
return n;
}

int main()
{
int i, caseNum, N, K, P, j;
caseNum = getInt();
for (i = 1; i <= caseNum; i ++)
{
N = getInt(), K = getInt(), P = getInt();
j = (K + P) % N;
if (j == 0) j = N;
printf("Case %d: %d\n", i, j);
}
return 0;
}


回目錄
回首頁

ACM 10589 - Area

#include <stdio.h>

int main()
{
double N, a, x, y, i, in;
while (1)
{
scanf("%lf %lf", &N, &a);
if (N == 0 && a == 0) break;
in = 0;
for (i = 0 ; i < N; i++)
{
scanf("%lf %lf", &x, &y);
if (x*x + y*y < a*a && x*x + (a-y)*(a-y) < a*a &&
(a-x)*(a-x) + (a-y)*(a-y) < a*a && (a-x)*(a-x) + y*y < a*a)
in ++;
}
printf("%.5lf\n", (in/N)*a*a);
}
return 0;
}


回目錄
回首頁

ACM 10583 - Ubiquitous Religions

#include <stdio.h>
#include <memory.h>
int n, m;

int getInt()
{
char ch;
int n = 0;
while( ch = getchar())
if(ch != ' ' && ch != '\n') break;
n = ch - 48;
while( ch = getchar())
{
if(ch == ' ' || ch == '\n') break;
n = n * 10 + ch - 48;
}
return n;
}

int main()
{
int caseNum = 1, s, i, j, religionID, count, tmp, replace;
while ((n = getInt()) && (m = getInt()))
{
int student[n + 1];
religionID = 1, count = 0;
memset(student, 0, sizeof(student));
while (m --)
{
i = getInt(), j = getInt();
if (student[i] == 0 && student[j] == 0)
{
student[i] = religionID, student[j] = religionID;
religionID ++;
count ++;
}
else if((student[i] != 0 && student[j] == 0) ||
(student[i] == 0 && student[j] != 0))
{
tmp = student[i] < student[j] ? student[j] : student[i];
student[i] = tmp, student[j] = tmp;
}
else if (student[i] != student[j])
{
tmp = student[j];
replace = student[i];
for (s = 1; s <= n; s ++)
if (student[s] == tmp) student[s] = replace;
count --;
}
}
/* for (i = 1; i <= n; i ++)
printf("%d ", student[i]);
printf("\n"); */
for (i = 1; i <= n; i ++)
if (student[i] == 0) count ++;
printf("Case %d: %d\n", caseNum ++, count);

}
return 0;
}


回目錄
回首頁

ACM 10608 - Friends

#include <stdio.h>
#include <memory.h>
#define SIZE 30000

int getInt()
{
char ch;
int n = 0;
while( ch = getchar())
if(ch != ' ' && ch != '\n') break;
n = ch - 48;
while( ch = getchar())
{
if(ch == ' ' || ch == '\n') break;
n = n * 10 + ch - 48;
}
return n;
}

int main()
{

int caseNum, a, b, s, n, m, count, groupID, tmp, replace;
caseNum = getInt();
while (caseNum --)
{
n = getInt(), m = getInt();
int friends[n + 1], record[n + 1], max = 0;
count = 0, groupID = 1;
memset(friends, 0, sizeof(friends));
memset(record, 0, sizeof(record));
while (m --)
{
a = getInt(), b = getInt();
if (friends[a] == 0 && friends[b] == 0)
{
friends[a] = groupID, friends[b] = groupID;
record[groupID] = 2;
if (max < record[groupID]) max = record[groupID];

groupID ++;
count ++;
}
else if((friends[a] != 0 && friends[b] == 0) ||
(friends[a] == 0 && friends[b] != 0))
{
tmp = friends[a] < friends[b] ? friends[b] : friends[a];
friends[a] = tmp, friends[b] = tmp;
record[tmp] ++;
if (max < record[tmp]) max = record[tmp];
}
else if (friends[a] != friends[b])
{
tmp = friends[b];
replace = friends[a];
record[tmp] = 0;
for (s = 1; s <= n; s ++)
if (friends[s] == tmp) friends[s] = replace, record[replace] ++;
if (max < record[replace]) max = record[replace];
count --;
}
/* for (s = 1; s <= n; s ++)
printf("%d ", record[s]);
printf("\n"); */
}
printf("%d\n", max);
}

return 0;
}


回目錄
回首頁

ACM 11764 - Jumping Mario

#include <stdio.h>
int T, N, low, high;
int main()
{
int i, j, num, record;
scanf("%d", &T);
for (i = 1; i <= T; i ++)
{
low = 0, high = 0;
scanf("%d%d", &N, &record), N --;
while (N --)
{
scanf("%d", &num);
if (record > num) low ++;
if (record < num) high ++;
record = num;
}
printf("Case %d: %d %d\n", i, high, low);
}
return 0;
}


回目錄
回首頁

ACM 11715 - Car

#include <stdio.h>
#include <math.h>
double u, v, t, s, a;

int main()
{
int n, caseNum = 1;
while( scanf("%d", &n) == 1 && n)
{
printf("Case %d: ", caseNum ++);
switch (n)
{
case 1:
scanf("%lf %lf %lf", &u, &v, &t);
a = (v - u) / t;
s = (v * v - u * u) / (2 * a);
printf("%.3lf %.3lf\n", s, a);
break;
case 2:
scanf("%lf %lf %lf", &u, &v, &a);
t = (v - u) / a;
s = (v * v - u * u) / (2 * a);
printf("%.3lf %.3lf\n", s, t);
break;
case 3:
scanf("%lf %lf %lf", &u, &a, &s);
v = sqrt((u * u + 2 * a * s));
t = (v - u) / a;
printf("%.3lf %.3lf\n", v, t);
break;
case 4:
scanf("%lf %lf %lf", &v, &a, &s);
u = sqrt((v * v - 2 * a * s));
t = (v - u) / a;
printf("%.3lf %.3lf\n", u, t);
break;
}
}

return 0;
}


回目錄
回首頁

ACM 11714 - Blind Sorting

#include <stdio.h>
#include <math.h>
int n;

int main()
{
while (scanf("%d", &n) == 1)
{
printf("%d\n", (n - 1) + (int)(log(n - 1) / log(2)));
}
return 0;
}


回目錄
回首頁

ACM 11703 - sqrt log sin

#include <stdio.h>
#include <math.h>

int X[1000001];

void create()
{
X[0] = 1;
int i;
for (i = 1; i < 1000001; i ++)
{
X[i] = X[(int)floor(i - sqrt(i))] +
X[(int)floor(log(i))] +
X[(int)floor(i * sin(i) * sin(i))];
X[i] %= 1000000;
}
}

int main()
{
create();
int n;
while (scanf("%d", &n) == 1 && n >= 0)
{
printf("%d\n", X[n]);
}
return 0;
}


回目錄
回首頁

ACM 11689 - Soda Surpler

#include <stdio.h>

int main()
{
int e, f, c, n;
scanf("%d", &n);
while (n --)
{
int total = 0, record;
scanf("%d %d %d", &e, &f, &c);
e += f;
for (; e > c;)
{
total += e / c;
record = e / c;
e = (e % c + record);
}
if (e == c) total ++;
printf("%d\n", total);
}
return 0;
}


回目錄
回首頁

ACM 11677 - Alarm Clock

#include <stdio.h>

int H1, M1, H2, M2, totalM;

int main()
{
while (scanf("%d %d %d %d", &H1, &M1, &H2, &M2) == 4)
{
if (H1 == 0 && H2 == 0 && M1 == 0 && M2 == 0) break;
if (H1 == H2 && M1 > M2 || H1 > H2) H2 += 24;
totalM = (M2 >= M1? (M2 - M1) + (H2 - H1) * 60: (60-M1+M2) + (H2 - H1 - 1) * 60);
printf("%d\n", totalM);
}
return 0;
}


回目錄
回首頁

ACM 11661 - Burger Time?

#include <stdio.h>
#include <limits.h>
#define inf INT_MAX
char str[2000002], ch;

int main()
{
int n, i;
while (scanf("%d", &n) == 1 && n)
{
getchar();
int R = 0, D = 0, Z = 0, min = inf, tmp;
gets(str);
for (i = 0; (ch = str[i]); i ++)
{
if (ch == '.') continue;
if (ch == 'D')
{
D = i + 1;
if (R) tmp = D - R;
if (tmp < min && R) min = tmp;
continue;
}
if (ch == 'R')
{
R = i + 1;
if (D) tmp = R - D;
if (tmp < min && D) min = tmp;
continue;
}
if (ch == 'Z')
{
min = inf;
break;
}
}
if (min == inf) printf("0\n");
else printf("%d\n", min);
}
return 0;
}


回目錄
回首頁

ACM 11650 - Mirror Clock

#include <stdio.h>
int main()
{
int H, M, T;
scanf("%d", &T);
while (T --)
{
scanf("%d:%d", &H, &M);
int revH, revM;
if (H >= 12) H -= 12;
if (H == 12 && M == 0 || H == 0 && M == 0) puts("12:00");
else
{
revH = (12 - H) - 1;
revM = 60 - M;
if (revM == 60) revM = 0, revH ++;
if (revH == 0) revH = 12;
printf("%02d:%02d\n", revH, revM);
}
}
return 0;
}


回目錄
回首頁

ACM 11636 - Hello World!

#include <stdio.h>
#include <math.h>
int main()
{
int n, j = 0;
while (scanf("%d", &n) && n > 0 )
if (n != 1) printf("Case %d: %d\n", ++ j, (int)ceil(log((double)n)/log(2)));
else printf("Case %d: 0\n", ++ j) ;
return 0;
}


回目錄
回首頁

ACM 11608 - No Problem

#include <stdio.h>

int main ()
{
int problemNumber;
int month [15];
int required [15];
int Case = 0;
while ( scanf ("%d", &problemNumber) )
{
if ( problemNumber < 0 )
return 0;
month [0] = problemNumber;
int i;
for ( i = 1; i < 13; i++ )
scanf ("%d", &month [i]);
for ( i = 0; i < 12; i++ )
scanf ("%d", &required [i]);
printf ("Case %d:\n", ++Case);
for ( i = 0; i < 12; i++ )
{
if ( problemNumber >= required [i] )
{
problemNumber -= required [i];
printf ("No problem! :D\n");
}
else
printf ("No problem. :(\n");
problemNumber += month [i + 1];
}
}
return 0;
}


回目錄
回首頁

ACM 11616 - Roman Numerals

#include <stdio.h>
#include <ctype.h>

char str[20];

int main()
{
int n, i, j, sum, k;
while (gets(str))
{
if (isalpha(str[0]))
{
sum = 0;
for (i = 0; str[i]; i ++)
{
if (str[i] == 'M')
{
if (str[i + 3] == 'M' && str[i + 2] == 'M' && str[i + 1] == 'M')
{ sum += 4000; i += 3; continue; }
if (str[i + 2] == 'M' && str[i + 1] == 'M')
{ sum += 3000; i += 2; continue; }
if (str[i + 1] == 'M') { sum += 2000; i += 1; continue; }
sum += 1000; continue;
}
if (str[i] == 'D')
{
if (str[i + 3] == 'C' && str[i + 2] == 'C' && str[i + 1] == 'C')
{ sum += 800; i += 3; continue; }
if (str[i + 2] == 'C' && str[i + 1] == 'C')
{ sum += 700; i += 2; continue; }
if (str[i + 1] == 'C') { sum += 600; i += 1; continue; }
sum += 500; continue;
}
if (str[i] == 'C')
{
if (str[i + 1] == 'M') { sum += 900; i += 1; continue; }
if (str[i + 1] == 'D') { sum += 400; i += 1; continue; }
if (str[i + 2] == 'C' && str[i + 1] == 'C')
{ sum += 300; i += 2; continue; }
if (str[i + 1] == 'C') { sum += 200; i += 1; continue; }
sum += 100; continue;
}
if (str[i] == 'L')
{
if (str[i + 3] == 'X' && str[i + 2] == 'X' && str[i + 1] == 'X')
{ sum += 80; i += 3; continue; }
if (str[i + 2] == 'X' && str[i + 1] == 'X')
{ sum += 70; i += 2; continue; }
if (str[i + 1] == 'X') { sum += 60; i += 1; continue; }
sum += 50; continue;
}
if (str[i] == 'X')
{
if (str[i + 1] == 'C') { sum += 90; i += 1; continue; }
if (str[i + 1] == 'L') { sum += 40; i += 1; continue; }
if (str[i + 2] == 'X' && str[i + 1] == 'X')
{ sum += 30; i += 2; continue; }
if (str[i + 1] == 'X') { sum += 20; i += 1; continue; }
sum += 10; continue;
}
if (str[i] == 'V')
{
if (str[i + 3] == 'I' && str[i + 2] == 'I' && str[i + 1] == 'I')
{ sum += 8; i += 3; continue; }
if (str[i + 2] == 'I' && str[i + 1] == 'I')
{ sum += 7; i += 2; continue; }
if (str[i + 1] == 'I') { sum += 6; i += 1; continue; }
sum += 5; continue;
}
if (str[i] == 'I')
{
if (str[i + 1] == 'X') { sum += 9; i += 1; continue; }
if (str[i + 1] == 'V') { sum += 4; i += 1; continue; }
if (str[i + 2] == 'I' && str[i + 1] == 'I')
{ sum += 3; i += 2; continue; }
if (str[i + 1] == 'I') { sum += 2; i += 1; continue; }
sum += 1; continue;
}
}
printf("%d\n", sum);
}
else
{
sscanf(str, "%d", &n);
for (;n >= 1000 && n; n -= 1000)
printf("M");
if (n / 100 == 9) printf("CM"), n -= 900;
for (;n >= 500 && n; n -= 500)
printf("D");
if (n / 100 == 4) printf("CD"), n -= 400;
for (;n >= 100 && n; n -= 100)
printf("C");
if (n / 10 == 9) printf("XC"), n -= 90;
for (;n >= 50 && n; n -= 50)
printf("L");
if (n / 10 == 4) printf("XL"), n -= 40;
for (;n >= 10 && n; n -= 10)
printf("X");
if (n == 9) printf("IX"), n -= 9;
for (;n >= 5 && n; n -= 5)
printf("V");
if (n == 4) printf("IV"), n -= 4;
for (;n >= 1 && n; n -= 1)
printf("I");
printf("\n");
}
}
return 0;
}


回目錄
回首頁

ACM 11614 - Etruscan Warriors Never Play Chess

#include <stdio.h>
#include <math.h>

int main()
{
int caseNum;
long long int S = 0, n, i;
scanf("%d", &caseNum);
while (caseNum --)
{
scanf("%lld", &S);
printf("%lld\n", (long long int)floor(sqrt( 2.0 * (double)S + 0.25 ) + 0.5) - 1) ;
}
return 0;
}


回目錄
回首頁

ACM 11609 - Teams

#include <stdio.h>
long long int p[10] = { 2, 1024, 976371285, 688423210, 905611805,
607723520, 235042059, 255718402, 494499948,
140625001};

int main()
{
int n, i, k, l;
long long int ans, tmp, m, copyM, j;
scanf("%d", &n);
for (i = 1; i <= n; i ++)
{
ans = 1;
scanf("%lld", &m);
copyM = m;
m --;
for (j = 1000000000, k = 9; j > 0; j /= 10, k --)
{
tmp = m / j;
m %= j;
if (tmp)
{
while (tmp --)
ans = ( ans * p[k]) % 1000000007;
}
}

ans = (ans * copyM) % 1000000007;
printf("Case #%d: %lld\n", i, ans);
}

return 0;
}


回目錄
回首頁

ACM 11597 - Spanning Subtree

#include <stdio.h>

int main()
{
int n, j = 1;
while (scanf("%d", &n) == 1 && n)
{
printf("Case %d: %d\n", j++, n >> 1);
}
return 0;
}


回目錄
回首頁

ACM 11586 - Train Tracks

#include <stdio.h>

char str[200];

int main()
{
int caseNum, M, F, i;
scanf("%d", &caseNum);
getchar();
while (caseNum --)
{
gets(str);
M = 0, F = 0;
for (i = 0; str[i]; i ++)
{
if (str[i] == 'M') M ++;
if (str[i] == 'F') F ++;
}
if (M == F && M != 1 && F != 1) printf("LOOP\n");
else printf("NO LOOP\n");
}
return 0;
}


回目錄
回首頁

ACM 11547 - Automatic Answer

#include <stdio.h>

int main()
{
int caseNum, n;
scanf("%d", &caseNum);
while (caseNum --)
{
scanf("%d", &n);
n = ((n * 63) + 7492) * 5 - 498;
if (n < 0) n = -n;
printf("%d\n", (n / 10) % 10);
}
return 0;
}


回目錄
回首頁

ACM 11541 - Decoding

#include <stdio.h>
#include <ctype.h>
char str[400], ch;
int count;
int main()
{
int caseNum, i, j, k, isPut;
scanf("%d", &caseNum);
for (i = 1; i <= caseNum; i ++)
{
printf("Case %d: ", i);
scanf("%s", str);
for (j = 0; str[j]; j ++)
{
if (isalpha(str[j])) ch = str[j], isPut = 1, count = 0;
else if (isPut && isdigit(str[j]))
count = count * 10 + str[j] - '0';
if (isPut && str[j + 1] == '\0' || !isdigit(str[j + 1]) && count > 0)
{
while (count --)
printf("%c", ch);
isPut = 0;
}
}
printf("\n");
}
return 0;
}


回目錄
回首頁

ACM 11538 - Chess Queen

#include <stdio.h>
int main()
{
unsigned long long int n, m, total, tmp;
while (scanf("%llu %llu", &m, &n) == 2 && m && n)
{
if (m < n) tmp = m, m = n, n = tmp;
total = m*(m-1)*n+n*(n-1)*m+(n*(n-1)*(2*n-1)/6-(n-1)*n/2)*4+2*n*(n-1)*(m-n+1);
printf("%llu\n", total);
}
return 0;
}


回目錄
回首頁

ACM 11530 - SMS Typing

#include <stdio.h>
int keyNum[26] = {1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,4,1,2,3,1,2,3,4};
int count;
char str[101];
void Counter(char ch)
{
if (ch == ' ') count ++;
count += keyNum[ch - 'a'];
}

int main()
{
int n = 1, i, j;
scanf("%d", &n);
getchar();
for (j = 1; j <= n; j ++)
{
gets(str);
count = 0;
for (i = 0; str[i]; i ++)
Counter(str[i]);
printf("Case #%d: %d\n",j , count);
}
return 0;
}


回目錄
回首頁

ACM 11526 - H(n)

#include <stdio.h>
#include <math.h>

int main()
{
long int n, Hn, count, i;
int caseNum, sqrtN;
scanf("%d", &caseNum);
while (caseNum --)
{
scanf("%ld", &n);
Hn = 0;
sqrtN = (int)sqrt(n);
for (i = 1; i <= sqrtN; i ++)
{
count = (n/i) - (n/(i + 1));
if (i == n / i) Hn += (n / i);
else Hn += i * count + (n / i);
}
printf("%ld\n", Hn);

}
return 0;
}


回目錄
回首頁

ACM 11520 - Fill the Square

#include <stdio.h>

char square[11][11];
int n;
char ch = 'A';
int isSame(int row, int col, char ch)
{
if (row != 0)
{
if (ch == square[row - 1][col])
return 0;
}
if (row != n)
{
if (ch == square[row + 1][col])
return 0;
}
if (col != 0)
{
if (ch == square[row][col - 1])
return 0;
}
if (col != n)
{
if (ch == square[row][col + 1])
return 0;
}
return 1;
}

int main()
{
int caseNum, i, j, k, t;

scanf("%d", &caseNum);
for (t = 1; t <= caseNum; t++)
{
scanf("%d", &n);
for (i = 0; i < n; i ++)
scanf("%s", square[i]);
printf("Case %d:\n", t);
for (i = 0; i < n; i ++, printf("\n"))
for (j = 0; j < n; j ++)
{
if (square[i][j] != '.')
{
printf("%c", square[i][j]);
continue;
}
else
{
for (k = 0; k < 26; k ++)
if (isSame(i, j, ch + k))
{
printf("%c", ch + k);
square[i][j] = ch + k;
break;
}
}
}
}
return 0;
}


回目錄
回首頁

ACM 11498 - Division of Nlogonia

#include <stdio.h>

char ans[5][8] = {"NE", "SE", "NO", "SO", "divisa"};

int main()
{
int K, N, M, X, Y, site = 0;
while (scanf("%d", &K) == 1 && K)
{
scanf("%d %d", &N, &M);
while (K --)
{
site = 0;
scanf("%d %d", &X, &Y);
if (N == X || M == Y) { printf("%s\n", ans[4]); continue; }
if (X < N) site += 2;
if (Y < M) site += 1;
printf("%s\n", ans[site]);
}
}
return 0;
}


回目錄
回首頁

ACM 11462 - Age Sort

#include <stdio.h>

int n, data[101];
char in [3000000];
void input()
{
char ch;
int i, j = 0;
fgets(in, 2999999, stdin);
for (i = 0; (ch = in[i]); i ++)
{
if (ch == ' ' || ch == '\n')
{
data[j] ++;
j = 0;
continue;
}
j = (j * 10) + ch - '0';
continue;
}
}

void output()
{
int index = 0, i, j, now = 0;
for (i = 0; i < 10 && now != n; i ++)
for (;data[i] && now != n; data[i] --, now ++)
{
in[index ++] = i + '0';
in[index ++] = ' ';
continue;
}
for (i = 10; i < 100 && now != n; i ++)
for (;data[i] && now != n; data[i] --, now ++)
{
in[index ++] = (i / 10) + '0';
in[index ++] = (i % 10) + '0';
in[index ++] = ' ';
continue;
}
in[index - 1] = '\n';
in[index] = '\0';
fputs(in, stdout);
}

int main()
{
for (;scanf("%d", &n) == 1 && n;)
{
getchar();
input();
output();
continue;
}
return 0;
}


回目錄
回首頁

ACM 11401 - Triangle Counting

#include <stdio.h>

unsigned long long int ans[1000001];

void create()
{
int i;
unsigned long long int s, b, now;
ans[3] = 0;
ans[4] = 1;
for (i = 5; i < 1000001; i ++)
{
s = i;
b = i / 2 + 1;
now = s*(s-1)-(s+1)*(s-b)-b*(b-1);
ans[i] = ans[i - 1] + now;
}
}

int main()
{
int n;
create();
while (scanf("%d", &n) == 1 && n >= 3)
printf("%lld\n", ans[n]);
return 0;
}


回目錄
回首頁

ACM 11185 - Ternary

#include <stdio.h>

int threeCarry[19];

int creat()
{
int i, j;
for (i = 0, j = 1; i < 19; i ++, j *= 3)
threeCarry[i] = j;

}

int main()
{
creat();
int n, i;
while(scanf("%d", &n) == 1)
{
if (n < 0) break;
int isPut = 0;
if (n == 0)
{
printf("0\n");
continue;
}
for (i = 18; i >= 0; i --)
if (n / threeCarry[i] > 0)
printf("%d", n / threeCarry[i]), n %= threeCarry[i], isPut = 1;
else if (isPut)
printf("0");

printf("\n");
}

return 0;
}


回目錄
回首頁

ACM 11172 - Relational Operator

#include <stdio.h>

int main()
{
int n, i, m;

scanf("%d", &i);
while (i --)
{
scanf("%d %d", &n, &m);
if (n > m) printf(">\n");
if (n == m) printf("=\n");
if (n < m) printf("<\n");
}
return 0;
}


回目錄
回首頁

ACM 11150 - Cola

#include <stdio.h>

int main()
{
int n;
while (scanf("%d", &n) == 1)
{
int total = n, recode;
for (;n > 2;)
{
total += n / 3;
recode = n / 3;
n = (n % 3 + recode);
}
if (n == 2) total ++;
printf("%d\n", total);
}
return 0;
}


回目錄
回首頁

ACM 11121 - Base -2

#include <stdio.h>

int ans[50];

int abs(int n)
{
return n < 0? -n: n;
}

int main()
{
int n, m, index, i, a;
scanf("%d", &n);
a = n;
while (n --)
{
scanf("%d", &m);
index = 0;
for (;m != 1 && m != 0;)
{
int add = 0;
if (m < 0 && m % 2) add = 1;
ans[index ++] = abs(m % -2);
m /= -2;
if (add) m ++;
if(m == -1) ans[index ++] = 1, m = 1;

}
if (m == 1) ans[index ++] = 1;
printf("Case #%d: ", a - n);
for (i = index - 1; i >= 0; i --)
printf("%d", ans[i]);
if (m == 0) printf("%d", 0);
printf("\n");
}
return 0;
}


回目錄
回首頁

ACM 11069 - A Graph Problem

#include <stdio.h>
#define MAXLEN 77
int subSet[MAXLEN];
int main()
{
int i, n;
subSet[0] = 1, subSet[1] = 2, subSet[2] = 2;
for (i = 3; i < MAXLEN; i ++)
subSet[i] = subSet[i - 2] + subSet[i - 3];
while (1)
{
if (scanf("%d", &n) < 1) break;
printf("%d\n", subSet[n - 1]);
}
return 0;
}


回目錄
回首頁

ACM 11044 - Searching for Nessy

#include <stdio.h>
int numCase, m, n;
int main() {

scanf("%d", &numCase);
while (numCase --)
{
scanf("%d %d", &m, &n);
printf("%d\n", (m/3)*(n/3));
}
return 0;
}


回目錄
回首頁

ACM 11015 - 05-2 Rendezvous

#include <stdio.h>
#include <memory.h>
#define SIZE 23
struct Crew
{
char name[12];
};
struct Crew c[SIZE];
int W[SIZE][SIZE];

int main()
{
int n, m, caseNum = 1, i, j, k, min, minID;
while (scanf("%d %d", &n, &m) == 2 && n)
{
memset(W, 0, sizeof(W));
for (i = 1; i <= n; i ++)
scanf("%s", c[i].name);
while (m --)
{
scanf("%d %d %d", &i, &j, &k);
W[i][j] = W[j][i] = k;
}

for (k = 1; k <= n; k ++)
for (i = 1; i <= n; i ++)
for (j = 1; j <= n; j ++)
{
if (i != j && W[i][k] != 0 && W[k][j] != 0)
{
int m = W[i][k] + W[k][j];
if (W[i][j] == 0) W[i][j] = m;
else if (m < W[i][j]) W[i][j] = m;
}
}

for (i = 1, min = 0; i <= 1; i ++)
for (j = 1; j <= n; j ++)
if (i != j)
min += W[i][j];
minID = 1;
int count;
for (i = 2; i <= n; i ++)
{
for (j = 1, count = 0; j <= n; j ++)
{
if (i != j)
count += W[i][j];
}
if (min > count)
min = count, minID = i;
}
printf("Case #%d : %s\n", caseNum ++, c[minID].name);

}
return 0;
}


回目錄
回首頁

ACM 11005 - Cheapest Base

#include <stdio.h>
#include <ctype.h>
#define SIZE 37
int index, best[SIZE];
int money[SIZE];

int getMoney(int n, int base)
{
int nMoney = 0;
for (; n; n /= base)
{
nMoney += money[n % base];
}
return nMoney;
}

int main()
{
int n, i, m, j, k, min, count, caseNum;
scanf("%d", &n);
for (caseNum = 1; caseNum <= n; caseNum ++)
{
if (caseNum != 1) printf("\n");
index = 0;
for (i = 0; i < 36; i ++)
scanf("%d", &money[i]);
printf("Case %d:\n", caseNum);
scanf("%d", &m);
for (i = 0; i < m; i ++)
{
scanf("%d", &k);
index = 0;
min = getMoney(k, 2);
best[index ++] = 2;
for (j = 3; j <= 36; j ++)
{
count = getMoney(k, j);
if (min == count) best[index ++] = j;
if (min > count) min = count, index = 0, best[index ++] = j;
}
printf("Cheapest base(s) for number %d:", k);
for (j = 0; j < index; j ++)
printf(" %d", best[j]);
printf("\n");
}
}
return 0;
}


回目錄
回首頁

ACM 11000 - Bee

#include <stdio.h>
int main()
{
while (1)
{
long n, i;
scanf("%ld", &n);
if (n < 0) break;
long female[2], recode, male = 0,total = 0;
female[0] = 0, female[1] = 1;
if(n == 0)
{
printf("0 1\n");
continue;
}
else
for(i=1 ; i<=n ; i++)
{
male = female[1] + male;
recode = female[1] ,female[1] += female[0], female[0] = recode;
total = male + female[1];
}
printf("%ld %ld\n", male, total);
}
return 0;
}


回目錄
回首頁

ACM 10497 - Sweet Child Makes Trouble

#include <stdio.h>
#define SIZE 800
#define LEN 2000
int p[SIZE + 1][LEN + 1] = {0};
char output[SIZE + 1][LEN + 1];
void create()
{
int i;
p[0][0] = 1;
p[1][0] = 0;
output[0][0] = '1';
output[0][1] = '\0';
output[1][0] = '0';
output[1][1] = '\0';
int j, k, s, count = 0;
for (i = 2; i <= SIZE; i ++)
{
for (j = 0; j <= LEN; j ++)
{
p[i][j] += (p[i - 1][j] + p[i - 2][j]) * (i - 1);
p[i][j + 1] += p[i][j] / 10, p[i][j] %= 10;
}

for (j = LEN; j >= 0; j --)
if (p[i][j] > 0) break;
for (k = j, s = 0; k >= 0; k --, s ++)
output[i][s] = p[i][k] + '0';
output[i][s] = '\0';
}
}

int main()
{
int n;
create();
while (scanf("%d", &n) == 1 && n != -1)
puts(output[n]);
return 0;
}


回目錄
回首頁

ACM 10963 - The Swallowing Ground

#include <stdio.h>

int main()
{
int n, m, y1, y2, sub, error;
scanf("%d", &n);
while (n --)
{
error = 0;
scanf("%d", &m);
scanf("%d %d", &y1, &y2);
sub = y1 - y2;
m --;
while (m --)
{
scanf("%d %d", &y1, &y2);
if (sub != y1 - y2) error = 1;
}
if (error) printf("no\n");
else printf("yes\n");
if (n) printf("\n");
}

return 0;
}


回目錄
回首頁

ACM 10929 - You can say 11

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

char dig[10000];

int main()
{
int odd, even, i;
while(gets(dig))
{
if(!strcmp(dig,"0")) break;
odd = even = 0;
for(i = 0; dig[i]; i++)
{
if(i % 2) odd += dig[i] - '0';
else even += dig[i] -'0';
}
if((odd - even) % 11) printf("%s is not a multiple of 11.\n",dig);
else printf("%s is a multiple of 11.\n",dig);
}
return 0;
}


回目錄
回首頁

ACM 10919 - Prerequisites?

#include <stdio.h>
#define SIZE 101

int classID[SIZE];
int index, n, m, c, r;

int getInt()
{
char ch;
int n = 0;
while( ch = getchar())
if(ch != ' ' && ch != '\n') break;
n = ch - 48;
while( ch = getchar())
{
if(ch == ' ' || ch == '\n') break;
n = n * 10 + ch - 48;
}
return n;
}

int isFind(int low, int high, int n)
{
int mid;
if (low > high) return -1;
else
{
mid = (low + high) / 2;
if (n == classID[mid])
return mid;
else if (n < classID[mid])
return isFind(low, mid - 1, n);
else
return isFind(mid + 1, high, n);
}
}

int main()
{
int id, i, tmp;
while ((n = getInt()))
{
index = 0;
m = getInt();
while (n --)
{
id = getInt();
classID[index] = id;
for (i = index; i >= 1; i --)
if (classID[i] < classID[i - 1])
tmp = classID[i], classID[i] = classID[i - 1], classID[i - 1] = tmp;
else break;
index ++;
}
int error = 0, f;
while (m --)
{
c = getInt(), r = getInt();
int count = 0, find;
while (c --)
{
f = getInt();
find = isFind(0, index, f);
if (find != -1) count ++;
}
if (count < r) error = 1;
}
if (error) puts("no");
else puts("yes");
}
return 0;
}


回目錄
回首頁

ACM 10918 - Tri Tiling

#include <stdio.h>
#include <stdlib.h>

int tiling[16];


int main()
{
tiling[0] = 1;
tiling[1] = 3;
int i;
for (i = 2; i < 16; i ++)
tiling[i] = tiling[i - 1] * 4 - tiling[i - 2];
while (1)
{
scanf("%d", &i);
if (i < 0) break;
if (i % 2 == 1) printf("0\n");
else printf("%d\n", tiling[i/2]);
}

return 0;
}


回目錄
回首頁

ACM 10916 - Factstone Benchmark

#include <stdio.h>
#include <math.h>

int main()
{
double bit2, fac;
int n, i, y;
while (scanf("%d", &n) == 1 && n)
{
y = ((n - 1960) / 10);
bit2 = 4;

while(y --)
bit2 *= 2;
bit2 = bit2 * log(2.0);
double j = 1;
fac = 0;
for (i = 1; fac < bit2; i ++)
fac += log(i);
printf("%d\n", i - 2);
}
return 0;
}


回目錄
回首頁

ACM 10912 - Simple Minded Hashing

#include <stdio.h>
#define N 26
#define M 351

int a[N + 1][M + 1] = { {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 5, 6, 9, 11, 15, 18, 23, 27, 34, 39, 47, 54, 64, 72, 84, 94, 108, 120, 136, 149, 167, 181, 199, 214, 233, 247, 266, 280, 298, 311, 328, 339, 355, 364, 377, 384, 395, 398, 406, 406, 410, 406, 406, 398, 395, 384, 377, 364, 355, 339, 328, 311, 298, 280, 266, 247, 233, 214, 199, 181, 167, 149, 136, 120, 108, 94, 84, 72, 64, 54, 47, 39, 34, 27, 23, 18, 15, 11, 9, 6, 5, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 5, 7, 10, 13, 18, 23, 30, 37, 47, 57, 70, 84, 101, 119, 141, 164, 192, 221, 254, 289, 329, 370, 415, 462, 513, 565, 621, 677, 737, 797, 859, 921, 985, 1047, 1110, 1171, 1232, 1289, 1345, 1396, 1445, 1489, 1528, 1562, 1592, 1615, 1633, 1645, 1651, 1651, 1645, 1633, 1615, 1592, 1562, 1528, 1489, 1445, 1396, 1345, 1289, 1232, 1171, 1110, 1047, 985, 921, 859, 797, 737, 677, 621, 565, 513, 462, 415, 370, 329, 289, 254, 221, 192, 164, 141, 119, 101, 84, 70, 57, 47, 37, 30, 23, 18, 13, 10, 7, 5, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 5, 7, 11, 14, 20, 26, 35, 44, 58, 71, 90, 110, 136, 163, 199, 235, 282, 330, 389, 450, 525, 600, 690, 782, 889, 997, 1123, 1247, 1390, 1532, 1691, 1848, 2024, 2193, 2381, 2562, 2759, 2945, 3148, 3335, 3537, 3722, 3917, 4092, 4278, 4437, 4605, 4746, 4891, 5006, 5126, 5211, 5299, 5353, 5406, 5424, 5444, 5424, 5406, 5353, 5299, 5211, 5126, 5006, 4891, 4746, 4605, 4437, 4278, 4092, 3917, 3722, 3537, 3335, 3148, 2945, 2759, 2562, 2381, 2193, 2024, 1848, 1691, 1532, 1390, 1247, 1123, 997, 889, 782, 690, 600, 525, 450, 389, 330, 282, 235, 199, 163, 136, 110, 90, 71, 58, 44, 35, 26, 20, 14, 11, 7, 5, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 5, 7, 11, 15, 21, 28, 38, 49, 65, 82, 105, 131, 164, 201, 248, 300, 363, 434, 518, 611, 721, 841, 979, 1131, 1303, 1489, 1699, 1924, 2173, 2440, 2732, 3041, 3377, 3729, 4106, 4500, 4917, 5347, 5800, 6262, 6741, 7228, 7727, 8227, 8736, 9240, 9744, 10240, 10729, 11201, 11662, 12099, 12515, 12904, 13265, 13591, 13886, 14141, 14357, 14533, 14666, 14754, 14800, 14800, 14754, 14666, 14533, 14357, 14141, 13886, 13591, 13265, 12904, 12515, 12099, 11662, 11201, 10729, 10240, 9744, 9240, 8736, 8227, 7727, 7228, 6741, 6262, 5800, 5347, 4917, 4500, 4106, 3729, 3377, 3041, 2732, 2440, 2173, 1924, 1699, 1489, 1303, 1131, 979, 841, 721, 611, 518, 434, 363, 300, 248, 201, 164, 131, 105, 82, 65, 49, 38, 28, 21, 15, 11, 7, 5, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 5, 7, 11, 15, 22, 29, 40, 52, 70, 89, 116, 146, 186, 230, 288, 351, 432, 521, 631, 752, 900, 1060, 1252, 1461, 1707, 1972, 2281, 2611, 2991, 3395, 3853, 4338, 4883, 5453, 6087, 6748, 7474, 8224, 9042, 9879, 10783, 11702, 12683, 13672, 14721, 15765, 16862, 17946, 19072, 20171, 21304, 22394, 23507, 24563, 25627, 26620, 27611, 28512, 29399, 30186, 30945, 31590, 32200, 32684, 33125, 33434, 33692, 33814, 33885, 33814, 33692, 33434, 33125, 32684, 32200, 31590, 30945, 30186, 29399, 28512, 27611, 26620, 25627, 24563, 23507, 22394, 21304, 20171, 19072, 17946, 16862, 15765, 14721, 13672, 12683, 11702, 10783, 9879, 9042, 8224, 7474, 6748, 6087, 5453, 4883, 4338, 3853, 3395, 2991, 2611, 2281, 1972, 1707, 1461, 1252, 1060, 900, 752, 631, 521, 432, 351, 288, 230, 186, 146, 116, 89, 70, 52, 40, 29, 22, 15, 11, 7, 5, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 5, 7, 11, 15, 22, 30, 41, 54, 73, 94, 123, 157, 201, 252, 317, 391, 484, 591, 720, 868, 1046, 1246, 1482, 1749, 2058, 2404, 2802, 3242, 3743, 4295, 4913, 5590, 6344, 7160, 8059, 9029, 10085, 11215, 12437, 13732, 15121, 16585, 18136, 19759, 21469, 23239, 25086, 26988, 28951, 30954, 33006, 35077, 37179, 39284, 41392, 43482, 45557, 47584, 49570, 51490, 53339, 55097, 56763, 58311, 59745, 61045, 62204, 63213, 64071, 64759, 65282, 65634, 65809, 65809, 65634, 65282, 64759, 64071, 63213, 62204, 61045, 59745, 58311, 56763, 55097, 53339, 51490, 49570, 47584, 45557, 43482, 41392, 39284, 37179, 35077, 33006, 30954, 28951, 26988, 25086, 23239, 21469, 19759, 18136, 16585, 15121, 13732, 12437, 11215, 10085, 9029, 8059, 7160, 6344, 5590, 4913, 4295, 3743, 3242, 2802, 2404, 2058, 1749, 1482, 1246, 1046, 868, 720, 591, 484, 391, 317, 252, 201, 157, 123, 94, 73, 54, 41, 30, 22, 15, 11, 7, 5, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 5, 7, 11, 15, 22, 30, 42, 55, 75, 97, 128, 164, 212, 266, 338, 419, 523, 641, 788, 954, 1159, 1388, 1664, 1974, 2342, 2750, 3231, 3760, 4374, 5048, 5820, 6661, 7617, 8650, 9810, 11059, 12448, 13929, 15565, 17298, 19192, 21188, 23349, 25607, 28037, 30555, 33239, 36004, 38926, 41908, 45038, 48206, 51499, 54806, 58214, 61600, 65064, 68467, 71911, 75262, 78618, 81834, 85023, 88031, 90971, 93694, 96314, 98674, 100905, 102842, 104616, 106076, 107350, 108283, 109021, 109406, 109583, 109406, 109021, 108283, 107350, 106076, 104616, 102842, 100905, 98674, 96314, 93694, 90971, 88031, 85023, 81834, 78618, 75262, 71911, 68467, 65064, 61600, 58214, 54806, 51499, 48206, 45038, 41908, 38926, 36004, 33239, 30555, 28037, 25607, 23349, 21188, 19192, 17298, 15565, 13929, 12448, 11059, 9810, 8650, 7617, 6661, 5820, 5048, 4374, 3760, 3231, 2750, 2342, 1974, 1664, 1388, 1159, 954, 788, 641, 523, 419, 338, 266, 212, 164, 128, 97, 75, 55, 42, 30, 22, 15, 11, 7, 5, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 5, 7, 11, 15, 22, 30, 42, 56, 76, 99, 131, 169, 218, 276, 351, 438, 548, 676, 833, 1015, 1236, 1489, 1791, 2137, 2543, 3004, 3541, 4144, 4838, 5615, 6497, 7478, 8583, 9800, 11159, 12648, 14293, 16082, 18045, 20162, 22465, 24935, 27596, 30430, 33463, 36666, 40067, 43636, 47391, 51303, 55390, 59612, 63986, 68473, 73079, 77765, 82538, 87346, 92198, 97046, 101884, 106669, 111396, 116013, 120518, 124865, 129041, 133006, 136752, 140234, 143448, 146360, 148955, 151212, 153123, 154662, 155830, 156613, 157004, 157004, 156613, 155830, 154662, 153123, 151212, 148955, 146360, 143448, 140234, 136752, 133006, 129041, 124865, 120518, 116013, 111396, 106669, 101884, 97046, 92198, 87346, 82538, 77765, 73079, 68473, 63986, 59612, 55390, 51303, 47391, 43636, 40067, 36666, 33463, 30430, 27596, 24935, 22465, 20162, 18045, 16082, 14293, 12648, 11159, 9800, 8583, 7478, 6497, 5615, 4838, 4144, 3541, 3004, 2543, 2137, 1791, 1489, 1236, 1015, 833, 676, 548, 438, 351, 276, 218, 169, 131, 99, 76, 56, 42, 30, 22, 15, 11, 7, 5, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 5, 7, 11, 15, 22, 30, 42, 56, 77, 100, 133, 171, 222, 281, 359, 448, 563, 695, 860, 1049, 1283, 1547, 1868, 2232, 2666, 3154, 3731, 4374, 5125, 5959, 6919, 7979, 9190, 10514, 12012, 13644, 15470, 17445, 19639, 21993, 24586, 27353, 30371, 33571, 37038, 40683, 44601, 48697, 53061, 57589, 62381, 67312, 72490, 77781, 83288, 88871, 94641, 100433, 106369, 112280, 118279, 124191, 130141, 135934, 141705, 147256, 152717, 157891, 162920, 167588, 172052, 176102, 179888, 183205, 186218, 188712, 190866, 192473, 193708, 194377, 194668, 194377, 193708, 192473, 190866, 188712, 186218, 183205, 179888, 176102, 172052, 167588, 162920, 157891, 152717, 147256, 141705, 135934, 130141, 124191, 118279, 112280, 106369, 100433, 94641, 88871, 83288, 77781, 72490, 67312, 62381, 57589, 53061, 48697, 44601, 40683, 37038, 33571, 30371, 27353, 24586, 21993, 19639, 17445, 15470, 13644, 12012, 10514, 9190, 7979, 6919, 5959, 5125, 4374, 3731, 3154, 2666, 2232, 1868, 1547, 1283, 1049, 860, 695, 563, 448, 359, 281, 222, 171, 133, 100, 77, 56, 42, 30, 22, 15, 11, 7, 5, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 5, 7, 11, 15, 22, 30, 42, 56, 77, 101, 133, 172, 223, 283, 361, 452, 567, 702, 868, 1061, 1297, 1568, 1892, 2265, 2705, 3206, 3792, 4454, 5218, 6078, 7058, 8152, 9391, 10762, 12297, 13989, 15867, 17918, 20179, 22631, 25309, 28197, 31324, 34670, 38271, 42095, 46173, 50480, 55038, 59812, 64829, 70046, 75482, 81097, 86899, 92842, 98940, 105133, 111426, 117770, 124158, 130532, 136892, 143174, 149370, 155426, 161324, 167009, 172474, 177657, 182544, 187095, 191289, 195083, 198471, 201413, 203899, 205909, 207429, 208445, 208960, 208960, 208445, 207429, 205909, 203899, 201413, 198471, 195083, 191289, 187095, 182544, 177657, 172474, 167009, 161324, 155426, 149370, 143174, 136892, 130532, 124158, 117770, 111426, 105133, 98940, 92842, 86899, 81097, 75482, 70046, 64829, 59812, 55038, 50480, 46173, 42095, 38271, 34670, 31324, 28197, 25309, 22631, 20179, 17918, 15867, 13989, 12297, 10762, 9391, 8152, 7058, 6078, 5218, 4454, 3792, 3206, 2705, 2265, 1892, 1568, 1297, 1061, 868, 702, 567, 452, 361, 283, 223, 172, 133, 101, 77, 56, 42, 30, 22, 15, 11, 7, 5, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 5, 7, 11, 15, 22, 30, 42, 56, 77, 100, 133, 171, 222, 281, 359, 448, 563, 695, 860, 1049, 1283, 1547, 1868, 2232, 2666, 3154, 3731, 4374, 5125, 5959, 6919, 7979, 9190, 10514, 12012, 13644, 15470, 17445, 19639, 21993, 24586, 27353, 30371, 33571, 37038, 40683, 44601, 48697, 53061, 57589, 62381, 67312, 72490, 77781, 83288, 88871, 94641, 100433, 106369, 112280, 118279, 124191, 130141, 135934, 141705, 147256, 152717, 157891, 162920, 167588, 172052, 176102, 179888, 183205, 186218, 188712, 190866, 192473, 193708, 194377, 194668, 194377, 193708, 192473, 190866, 188712, 186218, 183205, 179888, 176102, 172052, 167588, 162920, 157891, 152717, 147256, 141705, 135934, 130141, 124191, 118279, 112280, 106369, 100433, 94641, 88871, 83288, 77781, 72490, 67312, 62381, 57589, 53061, 48697, 44601, 40683, 37038, 33571, 30371, 27353, 24586, 21993, 19639, 17445, 15470, 13644, 12012, 10514, 9190, 7979, 6919, 5959, 5125, 4374, 3731, 3154, 2666, 2232, 1868, 1547, 1283, 1049, 860, 695, 563, 448, 359, 281, 222, 171, 133, 100, 77, 56, 42, 30, 22, 15, 11, 7, 5, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 5, 7, 11, 15, 22, 30, 42, 56, 76, 99, 131, 169, 218, 276, 351, 438, 548, 676, 833, 1015, 1236, 1489, 1791, 2137, 2543, 3004, 3541, 4144, 4838, 5615, 6497, 7478, 8583, 9800, 11159, 12648, 14293, 16082, 18045, 20162, 22465, 24935, 27596, 30430, 33463, 36666, 40067, 43636, 47391, 51303, 55390, 59612, 63986, 68473, 73079, 77765, 82538, 87346, 92198, 97046, 101884, 106669, 111396, 116013, 120518, 124865, 129041, 133006, 136752, 140234, 143448, 146360, 148955, 151212, 153123, 154662, 155830, 156613, 157004, 157004, 156613, 155830, 154662, 153123, 151212, 148955, 146360, 143448, 140234, 136752, 133006, 129041, 124865, 120518, 116013, 111396, 106669, 101884, 97046, 92198, 87346, 82538, 77765, 73079, 68473, 63986, 59612, 55390, 51303, 47391, 43636, 40067, 36666, 33463, 30430, 27596, 24935, 22465, 20162, 18045, 16082, 14293, 12648, 11159, 9800, 8583, 7478, 6497, 5615, 4838, 4144, 3541, 3004, 2543, 2137, 1791, 1489, 1236, 1015, 833, 676, 548, 438, 351, 276, 218, 169, 131, 99, 76, 56, 42, 30, 22, 15, 11, 7, 5, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 5, 7, 11, 15, 22, 30, 42, 55, 75, 97, 128, 164, 212, 266, 338, 419, 523, 641, 788, 954, 1159, 1388, 1664, 1974, 2342, 2750, 3231, 3760, 4374, 5048, 5820, 6661, 7617, 8650, 9810, 11059, 12448, 13929, 15565, 17298, 19192, 21188, 23349, 25607, 28037, 30555, 33239, 36004, 38926, 41908, 45038, 48206, 51499, 54806, 58214, 61600, 65064, 68467, 71911, 75262, 78618, 81834, 85023, 88031, 90971, 93694, 96314, 98674, 100905, 102842, 104616, 106076, 107350, 108283, 109021, 109406, 109583, 109406, 109021, 108283, 107350, 106076, 104616, 102842, 100905, 98674, 96314, 93694, 90971, 88031, 85023, 81834, 78618, 75262, 71911, 68467, 65064, 61600, 58214, 54806, 51499, 48206, 45038, 41908, 38926, 36004, 33239, 30555, 28037, 25607, 23349, 21188, 19192, 17298, 15565, 13929, 12448, 11059, 9810, 8650, 7617, 6661, 5820, 5048, 4374, 3760, 3231, 2750, 2342, 1974, 1664, 1388, 1159, 954, 788, 641, 523, 419, 338, 266, 212, 164, 128, 97, 75, 55, 42, 30, 22, 15, 11, 7, 5, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 5, 7, 11, 15, 22, 30, 41, 54, 73, 94, 123, 157, 201, 252, 317, 391, 484, 591, 720, 868, 1046, 1246, 1482, 1749, 2058, 2404, 2802, 3242, 3743, 4295, 4913, 5590, 6344, 7160, 8059, 9029, 10085, 11215, 12437, 13732, 15121, 16585, 18136, 19759, 21469, 23239, 25086, 26988, 28951, 30954, 33006, 35077, 37179, 39284, 41392, 43482, 45557, 47584, 49570, 51490, 53339, 55097, 56763, 58311, 59745, 61045, 62204, 63213, 64071, 64759, 65282, 65634, 65809, 65809, 65634, 65282, 64759, 64071, 63213, 62204, 61045, 59745, 58311, 56763, 55097, 53339, 51490, 49570, 47584, 45557, 43482, 41392, 39284, 37179, 35077, 33006, 30954, 28951, 26988, 25086, 23239, 21469, 19759, 18136, 16585, 15121, 13732, 12437, 11215, 10085, 9029, 8059, 7160, 6344, 5590, 4913, 4295, 3743, 3242, 2802, 2404, 2058, 1749, 1482, 1246, 1046, 868, 720, 591, 484, 391, 317, 252, 201, 157, 123, 94, 73, 54, 41, 30, 22, 15, 11, 7, 5, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 5, 7, 11, 15, 22, 29, 40, 52, 70, 89, 116, 146, 186, 230, 288, 351, 432, 521, 631, 752, 900, 1060, 1252, 1461, 1707, 1972, 2281, 2611, 2991, 3395, 3853, 4338, 4883, 5453, 6087, 6748, 7474, 8224, 9042, 9879, 10783, 11702, 12683, 13672, 14721, 15765, 16862, 17946, 19072, 20171, 21304, 22394, 23507, 24563, 25627, 26620, 27611, 28512, 29399, 30186, 30945, 31590, 32200, 32684, 33125, 33434, 33692, 33814, 33885, 33814, 33692, 33434, 33125, 32684, 32200, 31590, 30945, 30186, 29399, 28512, 27611, 26620, 25627, 24563, 23507, 22394, 21304, 20171, 19072, 17946, 16862, 15765, 14721, 13672, 12683, 11702, 10783, 9879, 9042, 8224, 7474, 6748, 6087, 5453, 4883, 4338, 3853, 3395, 2991, 2611, 2281, 1972, 1707, 1461, 1252, 1060, 900, 752, 631, 521, 432, 351, 288, 230, 186, 146, 116, 89, 70, 52, 40, 29, 22, 15, 11, 7, 5, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 5, 7, 11, 15, 21, 28, 38, 49, 65, 82, 105, 131, 164, 201, 248, 300, 363, 434, 518, 611, 721, 841, 979, 1131, 1303, 1489, 1699, 1924, 2173, 2440, 2732, 3041, 3377, 3729, 4106, 4500, 4917, 5347, 5800, 6262, 6741, 7228, 7727, 8227, 8736, 9240, 9744, 10240, 10729, 11201, 11662, 12099, 12515, 12904, 13265, 13591, 13886, 14141, 14357, 14533, 14666, 14754, 14800, 14800, 14754, 14666, 14533, 14357, 14141, 13886, 13591, 13265, 12904, 12515, 12099, 11662, 11201, 10729, 10240, 9744, 9240, 8736, 8227, 7727, 7228, 6741, 6262, 5800, 5347, 4917, 4500, 4106, 3729, 3377, 3041, 2732, 2440, 2173, 1924, 1699, 1489, 1303, 1131, 979, 841, 721, 611, 518, 434, 363, 300, 248, 201, 164, 131, 105, 82, 65, 49, 38, 28, 21, 15, 11, 7, 5, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 5, 7, 11, 14, 20, 26, 35, 44, 58, 71, 90, 110, 136, 163, 199, 235, 282, 330, 389, 450, 525, 600, 690, 782, 889, 997, 1123, 1247, 1390, 1532, 1691, 1848, 2024, 2193, 2381, 2562, 2759, 2945, 3148, 3335, 3537, 3722, 3917, 4092, 4278, 4437, 4605, 4746, 4891, 5006, 5126, 5211, 5299, 5353, 5406, 5424, 5444, 5424, 5406, 5353, 5299, 5211, 5126, 5006, 4891, 4746, 4605, 4437, 4278, 4092, 3917, 3722, 3537, 3335, 3148, 2945, 2759, 2562, 2381, 2193, 2024, 1848, 1691, 1532, 1390, 1247, 1123, 997, 889, 782, 690, 600, 525, 450, 389, 330, 282, 235, 199, 163, 136, 110, 90, 71, 58, 44, 35, 26, 20, 14, 11, 7, 5, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 5, 7, 10, 13, 18, 23, 30, 37, 47, 57, 70, 84, 101, 119, 141, 164, 192, 221, 254, 289, 329, 370, 415, 462, 513, 565, 621, 677, 737, 797, 859, 921, 985, 1047, 1110, 1171, 1232, 1289, 1345, 1396, 1445, 1489, 1528, 1562, 1592, 1615, 1633, 1645, 1651, 1651, 1645, 1633, 1615, 1592, 1562, 1528, 1489, 1445, 1396, 1345, 1289, 1232, 1171, 1110, 1047, 985, 921, 859, 797, 737, 677, 621, 565, 513, 462, 415, 370, 329, 289, 254, 221, 192, 164, 141, 119, 101, 84, 70, 57, 47, 37, 30, 23, 18, 13, 10, 7, 5, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 5, 6, 9, 11, 15, 18, 23, 27, 34, 39, 47, 54, 64, 72, 84, 94, 108, 120, 136, 149, 167, 181, 199, 214, 233, 247, 266, 280, 298, 311, 328, 339, 355, 364, 377, 384, 395, 398, 406, 406, 410, 406, 406, 398, 395, 384, 377, 364, 355, 339, 328, 311, 298, 280, 266, 247, 233, 214, 199, 181, 167, 149, 136, 120, 108, 94, 84, 72, 64, 54, 47, 39, 34, 27, 23, 18, 15, 11, 9, 6, 5, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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