This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
for case in range(int(input())): | |
N = int(input()) | |
grid = [ input() for _ in range(N) ] | |
black = [ (r,c) for r in range(N) for c in range(N) if grid[r][c] == '#' ] | |
(r1,c1),(r2,c2) = black[0], black[-1] | |
size = r2 - r1 + 1 | |
rect = [ (r1+i,c1+j) for i in range(size) for j in range(size) ] | |
print('Case #{}: {}'.format(case + 1, "YES" if rect == black else "NO")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sys import stdin | |
for case in range(1, int(stdin.readline()) + 1): | |
L, N = stdin.readline().split() | |
N = int(N) | |
b = len(L) | |
n = 1 | |
while b**n < N: | |
N -= b**n | |
n += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 | |
141976667 113579661 391170920 | |
451206059 627065946 749652418 | |
676768891 736358526 311938017 | |
982606110 301318993 547385207 | |
162257290 810753529 528568774 | |
125567510 312214706 921252360 | |
338180051 673570368 438642619 | |
435874729 155125087 572058812 | |
315528113 500802098 91451398 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
N = 22 | |
e = 0 | |
for p in sum([[1/N, i/N] for i in range(1,N)], []): | |
e = (1 + e*p)/p | |
print(e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import numpy as np | |
N = 22 # number of prisoners | |
M = 2 # number of switches | |
def state(n,m): | |
# n is the number of uncounted prisoners | |
# m is the value of the counter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define MAX 10000000 | |
static int P[MAX+1]; | |
int main() { | |
for (int i = 2; i <= MAX; ++i) { | |
if (!P[i]) for (int j = i; j <= MAX; j += i) P[j]++; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <algorithm> | |
#include <assert.h> | |
#include <stdlib.h> | |
#include <vector> | |
#include <string> | |
#include <utility> | |
#include <iostream> | |
using namespace std; | |
typedef unsigned long long uint64; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <assert.h> | |
#include <stdlib.h> | |
#include <vector> | |
#include <string> | |
#include <utility> | |
#include <iostream> | |
using namespace std; | |
typedef unsigned long long uint64; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Score: 110 | |
4 0 4 3 | |
0 5 5 0 4 | |
4 5 0 5 5 0 | |
3 0 5 5 0 5 4 | |
4 5 0 5 5 0 | |
0 5 5 0 4 | |
4 0 4 3 | |
Score: 110 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
/* Tiles are labeled clockwise starting from the top. | |
Colors are r(ed), y(ellow), g(reen), b(lue). | |
Uppercase for head, lowercase for butt. */ | |
char tiles[9][4] = { | |
"yrGB", | |
"RbyG", | |
"BrbG", |
OlderNewer