Hiển thị các bài đăng có nhãn medium. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn medium. Hiển thị tất cả bài đăng

Thứ Ba, 8 tháng 1, 2019

UVa 12478 - Hardest Problem... (try one of the eight names)

Link:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=279&page=show_problem&problem=3922
Sol:
#include <cstdio>
int main()
{
printf("KABIR\n");
}

UVa 11956 - Brain**** (simulation; ignore '.')

Link:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=229&page=show_problem&problem=3107
Sol:
#include <cstdio>
int main()
{
char input[100001];
int mem[100];
int T, current;
scanf("%d", &T);
for (int t = 1; t <= T; ++t)
{
for (int i = 0; i < 100; ++i)
mem[i] = 0;
current = 0;
scanf("%s", &input);
for (int i = 0; input[i]; ++i)
{
switch (input[i])
{
case '>':
++current;
if (current == 100)
current = 0;
break;
case '<':
--current;
if (current == -1)
current = 99;
break;
case '+':
++mem[current];
if (mem[current] == 256)
mem[current] = 0;
break;
case '-':
--mem[current];
if (mem[current] == -1)
mem[current] = 255;
}
}
printf("Case %d:", t);
for (int i = 0; i < 100; ++i)
printf(" %02X", mem[i]);
printf("\n");
}
}

UVa 11683 - Laser Sculpture (one linear pass is enough)

Link:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=78&page=show_problem&problem=2730
Sol:
#include <cstdio>
int wantedSize[10010];
int main()
{
int height, length;
while (scanf("%d %d", &height, &length), height)
{
int count(0);
scanf("%d", &wantedSize[0]);
count += height - wantedSize[0];
for (int i = 1; i < length; ++i)
{
scanf("%d", &wantedSize[i]);
if (wantedSize[i] != height)
{
int temp = wantedSize[i - 1] - wantedSize[i];
if (temp > 0)
count += temp;
}
}
printf("%d\n", count);
}
}

UVa 11687 - Digits (simulation; straightforward)

Link:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=78&page=show_problem&problem=2734
Sol:
#include <cstdio>
#include <cstring>
int recurse(int length, int count)
{
if (length == 1)
return count + 1;
int newLength(0), oldLength(length);
for (; length; length /= 10, ++newLength);
return recurse(newLength, count + 1);
}
int main()
{
char input[1000010];
while (scanf("%s", input), input[0] != 'E')
{
if (strlen(input) == 1 && input[0] == '1')
printf("1\n");
else
printf("%d\n", recurse(strlen(input), 1));
}
}

Bài G - Educatioal Round 62

Đề bài: Bạn được cho 1 đồ thị vô hướng đặc biệt. Nó bao gồm $2n$ đỉnh được đánh số từ 1 đến 2n. Dưới đây là một số đặc tính của đồ thị: + ...