master
jakeallen 1 year ago
parent 22647d3898
commit 6df349d38e

@ -0,0 +1,89 @@
const int N = 1024;
void mm(int n, int A[][N], int B[][N], int C[][N]){
int i, j, k;
i = 0; j = 0;
while (i < n){
j = 0;
while (j < n){
C[i][j] = 0;
j = j + 1;
}
i = i + 1;
}
i = 0; j = 0; k = 0;
while (k < n){
i = 0;
while (i < n){
if (A[i][k] == 0){
i = i + 1;
continue;
}
j = 0;
while (j < n){
C[i][j] = C[i][j] + A[i][k] * B[k][j];
j = j + 1;
}
i = i + 1;
}
k = k + 1;
}
}
int A[N][N];
int B[N][N];
int C[N][N];
int main(){
int n = getint();
int i, j;
i = 0;
j = 0;
while (i < n){
j = 0;
while (j < n){
A[i][j] = getint();
j = j + 1;
}
i = i + 1;
}
i = 0;
j = 0;
while (i < n){
j = 0;
while (j < n){
B[i][j] = getint();
j = j + 1;
}
i = i + 1;
}
starttime();
i = 0;
while (i < 5){
mm(n, A, B, C);
mm(n, A, C, B);
i = i + 1;
}
int ans = 0;
i = 0;
while (i < n){
j = 0;
while (j < n){
ans = ans + B[i][j];
j = j + 1;
}
i = i + 1;
}
stoptime();
putint(ans);
putch(10);
return 0;
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,89 @@
const int N = 1024;
void mm(int n, int A[][N], int B[][N], int C[][N]){
int i, j, k;
i = 0; j = 0;
while (i < n){
j = 0;
while (j < n){
C[i][j] = 0;
j = j + 1;
}
i = i + 1;
}
i = 0; j = 0; k = 0;
while (k < n){
i = 0;
while (i < n){
if (A[i][k] == 0){
i = i + 1;
continue;
}
j = 0;
while (j < n){
C[i][j] = C[i][j] + A[i][k] * B[k][j];
j = j + 1;
}
i = i + 1;
}
k = k + 1;
}
}
int A[N][N];
int B[N][N];
int C[N][N];
int main(){
int n = getint();
int i, j;
i = 0;
j = 0;
while (i < n){
j = 0;
while (j < n){
A[i][j] = getint();
j = j + 1;
}
i = i + 1;
}
i = 0;
j = 0;
while (i < n){
j = 0;
while (j < n){
B[i][j] = getint();
j = j + 1;
}
i = i + 1;
}
starttime();
i = 0;
while (i < 5){
mm(n, A, B, C);
mm(n, A, C, B);
i = i + 1;
}
int ans = 0;
i = 0;
while (i < n){
j = 0;
while (j < n){
ans = ans + B[i][j];
j = j + 1;
}
i = i + 1;
}
stoptime();
putint(ans);
putch(10);
return 0;
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,89 @@
const int N = 1024;
void mm(int n, int A[][N], int B[][N], int C[][N]){
int i, j, k;
i = 0; j = 0;
while (i < n){
j = 0;
while (j < n){
C[i][j] = 0;
j = j + 1;
}
i = i + 1;
}
i = 0; j = 0; k = 0;
while (k < n){
i = 0;
while (i < n){
if (A[i][k] == 0){
i = i + 1;
continue;
}
j = 0;
while (j < n){
C[i][j] = C[i][j] + A[i][k] * B[k][j];
j = j + 1;
}
i = i + 1;
}
k = k + 1;
}
}
int A[N][N];
int B[N][N];
int C[N][N];
int main(){
int n = getint();
int i, j;
i = 0;
j = 0;
while (i < n){
j = 0;
while (j < n){
A[i][j] = getint();
j = j + 1;
}
i = i + 1;
}
i = 0;
j = 0;
while (i < n){
j = 0;
while (j < n){
B[i][j] = getint();
j = j + 1;
}
i = i + 1;
}
starttime();
i = 0;
while (i < 5){
mm(n, A, B, C);
mm(n, A, C, B);
i = i + 1;
}
int ans = 0;
i = 0;
while (i < n){
j = 0;
while (j < n){
ans = ans + B[i][j];
j = j + 1;
}
i = i + 1;
}
stoptime();
putint(ans);
putch(10);
return 0;
}

@ -0,0 +1,106 @@
const int base = 16;
int getMaxNum(int n, int arr[]){
int ret = 0;
int i = 0;
while (i < n){
if (arr[i] > ret) ret = arr[i];
i = i + 1;
}
return ret;
}
int getNumPos(int num, int pos){
int tmp = 1;
int i = 0;
while (i < pos){
num = num / base;
i = i + 1;
}
return num % base;
}
void radixSort(int bitround, int a[], int l, int r){
int head[base] = {};
int tail[base] = {};
int cnt[base] = {};
if (bitround == -1 || l + 1 >= r) return;
{
int i = l;
while (i < r){
cnt[getNumPos(a[i], bitround)]
= cnt[getNumPos(a[i], bitround)] + 1;
i = i + 1;
}
head[0] = l;
tail[0] = l + cnt[0];
i = 1;
while (i < base){
head[i] = tail[i - 1];
tail[i] = head[i] + cnt[i];
i = i + 1;
}
i = 0;
while (i < base){
while (head[i] < tail[i]){
int v = a[head[i]];
while (getNumPos(v, bitround) != i){
int t = v;
v = a[head[getNumPos(t, bitround)]];
a[head[getNumPos(t, bitround)]] = t;
head[getNumPos(t, bitround)] = head[getNumPos(t, bitround)] + 1;
}
a[head[i]] = v;
head[i] = head[i] + 1;
}
i = i + 1;
}
}
{
int i = l;
head[0] = l;
tail[0] = l + cnt[0];
i = 0;
while (i < base){
if (i > 0){
head[i] = tail[i - 1];
tail[i] = head[i] + cnt[i];
}
radixSort(bitround - 1, a, head[i], tail[i]);
i = i + 1;
}
}
return;
}
int a[30000010];
int ans;
int main(){
int n = getarray(a);
starttime();
radixSort(8, a, 0, n);
int i = 0;
while (i < n){
ans = ans + i * (a[i] % (2 + i));
i = i + 1;
}
if (ans < 0)
ans = -ans;
stoptime();
putint(ans);
putch(10);
return 0;
}

@ -0,0 +1,106 @@
const int base = 16;
int getMaxNum(int n, int arr[]){
int ret = 0;
int i = 0;
while (i < n){
if (arr[i] > ret) ret = arr[i];
i = i + 1;
}
return ret;
}
int getNumPos(int num, int pos){
int tmp = 1;
int i = 0;
while (i < pos){
num = num / base;
i = i + 1;
}
return num % base;
}
void radixSort(int bitround, int a[], int l, int r){
int head[base] = {};
int tail[base] = {};
int cnt[base] = {};
if (bitround == -1 || l + 1 >= r) return;
{
int i = l;
while (i < r){
cnt[getNumPos(a[i], bitround)]
= cnt[getNumPos(a[i], bitround)] + 1;
i = i + 1;
}
head[0] = l;
tail[0] = l + cnt[0];
i = 1;
while (i < base){
head[i] = tail[i - 1];
tail[i] = head[i] + cnt[i];
i = i + 1;
}
i = 0;
while (i < base){
while (head[i] < tail[i]){
int v = a[head[i]];
while (getNumPos(v, bitround) != i){
int t = v;
v = a[head[getNumPos(t, bitround)]];
a[head[getNumPos(t, bitround)]] = t;
head[getNumPos(t, bitround)] = head[getNumPos(t, bitround)] + 1;
}
a[head[i]] = v;
head[i] = head[i] + 1;
}
i = i + 1;
}
}
{
int i = l;
head[0] = l;
tail[0] = l + cnt[0];
i = 0;
while (i < base){
if (i > 0){
head[i] = tail[i - 1];
tail[i] = head[i] + cnt[i];
}
radixSort(bitround - 1, a, head[i], tail[i]);
i = i + 1;
}
}
return;
}
int a[30000010];
int ans;
int main(){
int n = getarray(a);
starttime();
radixSort(8, a, 0, n);
int i = 0;
while (i < n){
ans = ans + i * (a[i] % (2 + i));
i = i + 1;
}
if (ans < 0)
ans = -ans;
stoptime();
putint(ans);
putch(10);
return 0;
}

@ -0,0 +1,106 @@
const int base = 16;
int getMaxNum(int n, int arr[]){
int ret = 0;
int i = 0;
while (i < n){
if (arr[i] > ret) ret = arr[i];
i = i + 1;
}
return ret;
}
int getNumPos(int num, int pos){
int tmp = 1;
int i = 0;
while (i < pos){
num = num / base;
i = i + 1;
}
return num % base;
}
void radixSort(int bitround, int a[], int l, int r){
int head[base] = {};
int tail[base] = {};
int cnt[base] = {};
if (bitround == -1 || l + 1 >= r) return;
{
int i = l;
while (i < r){
cnt[getNumPos(a[i], bitround)]
= cnt[getNumPos(a[i], bitround)] + 1;
i = i + 1;
}
head[0] = l;
tail[0] = l + cnt[0];
i = 1;
while (i < base){
head[i] = tail[i - 1];
tail[i] = head[i] + cnt[i];
i = i + 1;
}
i = 0;
while (i < base){
while (head[i] < tail[i]){
int v = a[head[i]];
while (getNumPos(v, bitround) != i){
int t = v;
v = a[head[getNumPos(t, bitround)]];
a[head[getNumPos(t, bitround)]] = t;
head[getNumPos(t, bitround)] = head[getNumPos(t, bitround)] + 1;
}
a[head[i]] = v;
head[i] = head[i] + 1;
}
i = i + 1;
}
}
{
int i = l;
head[0] = l;
tail[0] = l + cnt[0];
i = 0;
while (i < base){
if (i > 0){
head[i] = tail[i - 1];
tail[i] = head[i] + cnt[i];
}
radixSort(bitround - 1, a, head[i], tail[i]);
i = i + 1;
}
}
return;
}
int a[30000010];
int ans;
int main(){
int n = getarray(a);
starttime();
radixSort(8, a, 0, n);
int i = 0;
while (i < n){
ans = ans + i * (a[i] % (2 + i));
i = i + 1;
}
if (ans < 0)
ans = -ans;
stoptime();
putint(ans);
putch(10);
return 0;
}

File diff suppressed because one or more lines are too long

@ -0,0 +1,50 @@
void spmv(int n,int xptr[], int yidx[], int vals[], int b[], int x[]){
int i, j, k;
i = 0;
while (i < n){
x[i] = 0;
i = i + 1;
}
i = 0;
while (i < n){
j = xptr[i];
while (j < xptr[i + 1]){
x[yidx[j]] = x[yidx[j]] + vals[j];
j = j + 1;
}
j = xptr[i];
while (j < xptr[i + 1]){
x[yidx[j]] = x[yidx[j]] + vals[j] * (b[i] - 1);
j = j + 1;
}
i = i + 1;
}
}
const int N = 100010;
const int M = 3000000;
int x[N], y[M], v[M];
int a[N], b[N], c[N];
int main(){
int n = getarray(x) - 1;
int m = getarray(y);
getarray(v);
getarray(a);
starttime();
int i = 0;
while (i < 100){
spmv(n, x, y, v, a, b);
spmv(n, x, y, v, b, a);
i=i+1;
}
stoptime();
putarray(n, b);
return 0;
}

File diff suppressed because one or more lines are too long

@ -0,0 +1,50 @@
void spmv(int n,int xptr[], int yidx[], int vals[], int b[], int x[]){
int i, j, k;
i = 0;
while (i < n){
x[i] = 0;
i = i + 1;
}
i = 0;
while (i < n){
j = xptr[i];
while (j < xptr[i + 1]){
x[yidx[j]] = x[yidx[j]] + vals[j];
j = j + 1;
}
j = xptr[i];
while (j < xptr[i + 1]){
x[yidx[j]] = x[yidx[j]] + vals[j] * (b[i] - 1);
j = j + 1;
}
i = i + 1;
}
}
const int N = 100010;
const int M = 3000000;
int x[N], y[M], v[M];
int a[N], b[N], c[N];
int main(){
int n = getarray(x) - 1;
int m = getarray(y);
getarray(v);
getarray(a);
starttime();
int i = 0;
while (i < 100){
spmv(n, x, y, v, a, b);
spmv(n, x, y, v, b, a);
i=i+1;
}
stoptime();
putarray(n, b);
return 0;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1,51 @@
50 50 353434
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
.....................#..#.........................
.....................#..#.........................
...................##.##.##.......................
.....................#..#.........................
.....................#..#.........................
...................##.##.##.......................
.....................#..#.........................
.....................#..#.........................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................

@ -0,0 +1,51 @@
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
......................##..........................
.....................####.........................
....................#....#........................
...................##....##.......................
...................##....##.......................
....................#....#........................
.....................####.........................
......................##..........................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
..................................................
0

@ -0,0 +1,285 @@
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
............................................................................................................................................##..................................................................................................................................................................
......................................................................................................................#.........#...........#...................................................................................................................................................................
......................................................................................................................###.....###.........#.#...............#...................................................................................................................................................
.........................................................................................................#...............#...#...........#.#................###.................................................................................................................................................
.......................................................................................................###..............##...##......##...#....................#..............#.................................................................................................................................
......................................................................................................#..............................##.......................##............###.................................................................................................................................
......................................................................................................##...................................................................#....................................................................................................................................
...........................................................................................................................................................................##...................................................................................................................................
...................................................................................................##.....##..........................................##........................................................................................................................................................
...................................................................................................#.#....##...........................#.............#.#........................................................................................................................................................
....................................................................................................##............#....................##............#....................##....................................................................................................................................
..................................................................................................................##.............##...#.#............###..#...............##....................................................................................................................................
.............................................................................................................##.....#..........####.....................##.#....................................................................................................................................................
............................................................................................................#..#...###........#....#....................##.#....................................................................................................................................................
.............................................................................................................###...##.###.....#..####.....................#.....................................................................................................................................................
.............................................................................................................##....#...##.....##.#.##...........................................................................................................................................................................
...................................................................................................................................##...........................................................................................................................................................................
................................................................................................................................###................................##...........................................................................................................................................
.....................................................................##..........................#........................................................##.......##...........................................................................................................................................
.....................................................................#.#........................#.#...................................##...................#......#..............##.......#.....................................................................................................................
.......................................................................#....##...................#................#......##...........#.#................#........###.......##..#..#.....#.#....................................................................................................................
...................................................................####.##..#..#................................###......##.............#................##........#.#......#.#..##......#.#....................................................................................................................
...................................................................#..#.#.#.#.##...............................#........................##...................##....##..........##.......##.###..................................................................................................................
......................................................................#.#.#.#...................................#.............................................#......#..........#.............#.........#.......................................................................................................
.......................................................................##.#.#..................................##..........................................###.......#.......#..#.##....##.###..........###.....................................................................................................
...........................................................................#.......................##......................................................#...........#....#.#.#..#....##.#...............#..............#.....................................................................................
..................................................................................................#.#.....#..................................................................##.##........................##............###.....................................................................................
.............................................................##...................................#.......##...........................................................................................................#........................................................................................
..............................................................#.......##.........................##......###...........................................................................................................##.......................................................................................
..............................................................#.#.....##..................................##.....##.#...........................................................................................................................................................................................
...............................................................##........................................##......#.##................................................................................###........................................................................................................
....................................................................................................................................................................................................##.##.............##........................................................................................
.............................................................................#...................................................................................................#.#................#..##.............##........................................................................................
..............................................................................##.................................................................................................#..#................##.........................................................................................................
.............................................................................##..............................................................................................##.#..#............................................................................................................................
.............................................................................................................................................................................#..#...............................................................................................................................
..............................................................................................................................................................................##................................................................................................................................
.....................................................##..................##...................................................................................##..............##................................................................................................................................
......................................................#..................#.......................#............................................................##..................................................##............................................................................................
....................................................#..........##.........###...................#.#.................................................................##................................##..........###...........................................................................................
....................................................#####.....#.#......###..#...................#.#.................................................................##.................................#.........#..#...........................................................................................
.........................................................#......#......#..#...................###.##.................................................................................................#..........##.##...........................................................................................
......................................................##.#..#........#.#..##.................#.......................................................................................................##.........##.##...##......................................................................................
.....................................................#...............##.......................###.##..............................................................##.....................................##......##.##..##......................................................................................
.....................................................##...#...##................................#.##..............................................................##.....##...............................#.........#...........................................................................................
...................................................##.......#............................................................................................................##............................###.......###............................................................................................
..................................................#..#.##.###..........................................................................................................................................#..........#.......#.....................................................................................
..................................................##.#.......................................#............#..........#...................................................................................................#.#....................................................................................
.....................................................#........................................#..........###.......###............................##......................................................................#.....................................................................................
.....................................................##.....................................###.........#.........#...............................##.....##................................................................###..................................................................................
.......................................................................................................##.##......##.....................................##..................................................................#..................................................................................
........................................................................................................##.##.........##........................................................................................................................................................................................
.............................................................##.........................................##.##..........#........................................................................................................................................................................................
..............................................................#...........#..........##.................#..#.........#.................................##.......................................................................................................................................................
...........................................................###...........##..........#..................###..........##................................##.......................................................................................................................................................
...........................................................#.............#.#...........#.................##..................................................##.................................................................................................................................................
...................................................................##..............#####.....................................................##..............##.................................................................................................................................................
....................................................................#.............#..........................................................##.................................................................................................................................................................
....................................................................#.#............###......................................................#..#................................................................................................................................................................
.....................................................................##...............#..............##..................................#..#.##................................................................................................................................................................
...................................................................................####............##..#..............##................#..#....................................................................................................................................................................
..............................................................................##...#...##...........#.##............##..#................#.#....................................................................................................................................................................
..............................................................................##....###..#.......##.##..............##.##.......................................................................................................................................................................................
......................................................................................#.##..##...###.................###................................................................................##.#......##............................................................................................
......................................................................................#.....#.#..#......................................................................................................#.##.....##.............................................................................................
.....................................................................................##......#...##..#...........................................................................................................###......##....................................................................................
..................................................................................................###............................................................................................................##.......#.....................................................................................
...................................................................................................#.............##........................##.##..................................................................#.....#.#.....................................................................................
..................................................................###........##..................................#...............#.##....#..#.#.#....#...........#......................................................##......................................................................................
.....................................................##.............#........#....................................###..........###.##....##.#..#.......#.......###..........................................##..................................................................................................
......................................................#............#..........###...................................#.........#.............#..........#......#.............................................#...................................................................................................
....................................................#...........................#..............................................###.##.......##..........##....##...................##........................#..................................................................................................
....................................................#####..............##...............#.##.........#...........................#.#......##..#.#......#.#........##................#.............##......###...................................................................................................
.........................................................#.............#................##.#.........#...........................#.#.....#..#..##.......###........#................#.#...........##......#................#....................................................................................
......................................................###............#.#.........................#.#..#...........................#.......##..............#......#...................##...................................#.#...................................................................................
.....................................................#...............##.........................##.#.#..................................................##.......##........................................................#....................................................................................
.....................................................####........................................#...##.................................................##................................###...................................................................................................................
...................................................##...#...##...................................#....#.................................................................................##......................................................................................................................
..................................................#..###....##........................................#.................................................................................##.#.##.....##...#....##................................................................................................
..................................................##.#..........................................#.....#...........................................................#.....................####..#.....###.##...###................................................................................................
.....................................................#..........................................##...#...........................................................#.##....................#....#........###...#..#...............................................................................................
.....................................................##............................................##............................................................#.##.....................####..........#.....##................................................................................................
......................................................................##..........................#..#...........................................##...............#..###............#.#...##.............##.....................................................................................................
.....................................................................##...........................#.#............................................##....................#............##....................#............##.......................................................................................
.............................................................##........#.........................##..................................................................#.#.............#...........................##....#.#......................................................................................
..............................................................#....................#.............#...................................................................##..........................................##.....##......................................................................................
...........................................................###...##..............#####..##..........##.......#..................................##..............................................................................................................................................................
...........................................................#......#.............#.....#..#..........##.....###...................................#...................................................................##.........................................................................................
..................................................................#.#............###..##............##....#...................................###............##.......................##..............................#.........................................................................................
...................................................................##...............#.#..........##.#....#.#..................................#..............#....................#...##......##...##..............###..........................................................................................
.................................................................................####..#..........###.....#...................................................###.##.............#.#...........#...#...............#............................................................................................
............................................................................##...#...##.#..........#............................................................#.##........##..#.#.........###.....###.........................................................................................................
............................................................................##....###...#.............................................................#.........#...........#...#...........#.........#.........................................................................................................
....................................................................................#...#.#.............##............................................###.....###.........#.#..##........##.#...................................................................................................................
....................................................................................#.##.##.............##...............................#...............#...#...........#.#.............##.###.................................................................................................................
...................................................................................##..#...............................................###..............##...##......##...#....................#..............#.................................................................................................
..................................................................##.................#.#..............................................#..............................##.......................##............###.................................................................................................
.....................................................##..........#.#.................##...............................................##...................................................................#....................................................................................................
......................................................#............#.......##..............................................................................................................................##...................................................................................................
....................................................#......................#.......................................................##.....##..............................................#.....................................................................................................................
....................................................#####..............##...###......##............................................#.#....##............................................##.##...................................................................................................................
.........................................................#.............#......#.......#.............................................##..................................................#.................##....................................................................................................
......................................................###............#.#..............#.#.......................................................###...................#.................#...#.............##....................................................................................................
.....................................................#...............##................##..##..................................................##...................##.##................###....................................................................................................................
.....................................................####..................................##.................................................#....#...#.........#####..........................................................................................................................................
...................................................##...#...##............................#...................................................##..##....#........#..#...........................................................................................................................................
..................................................#..###....##............................####......##............................................#....#.........#..#...........................................................................................................................................
..................................................##.#....................................#..###....#.#....................................#...........#..........##............................................................................................................................................
.....................................................#.....................................##..##.....#...............................##..##..........................................................#.#.......................................................................................................
.....................................................##........................................##.....##.........................#....#####.#.............................................##.........#..#.......................................................................................................
.......................................................................#.....................##.................................#.#...#..#.#..........................##...................#........##...#.......##.......#.....................................................................................
......................................................................##..........##.............................................#......###.......#......##...........#.#................#...............#..##..#..#.....#.#....................................................................................
.............................................................##.......#.#.........##...#..................................................#.....###......##.............#................##.................#.#..##......#.#....................................................................................
..............................................................#.......................#.#.................................................#....#........................##...................##.....###..#.....##.......##.###..................................................................................
...........................................................###........................#.#...............................................#####...#.............................................#.........##......#.............#.........#.......................................................................
...........................................................#...........................#................................................##.....##..........................................###.......###.....#..#.##....##.###..........###.....................................................................
...................................................................................................................................##......................................................#.........###....#.#.#..#....##.#...............#..............#.....................................................
..................................................................................................................................#.#........................................................................##.##........................##............###.....................................................
..................................................................................................................................#....................................................................................................................#........................................................
.................................................................................................................................##.....#.##...........................................................................................................##.......................................................
...................................................................................................#....................................#..#.....##.#.............................................................#.#...........................................................................................
....................................................................................................#...................................###......#.##.........................................................#...#.#...........................................................................................
..................................................................................................###.......#.............................#.........................................................................##................##..............##........................................................
..........................................................................................................#.#.............................##........................................................................#................##...............##........................................................
...........................................................................................................##.............................##..................................................................#.#.#...................#.........................................................................
..............................................................................................................................................................................................................###.#..#..........................................................................................
.....................................................................................###.......................................................................................................................#...#............................................................................................
.....................................................................................#...........#..............................................................................................................................................................................................................
...............................................................................##.....#........#####..........................................................................................##................................................................................................................
................................................................................#.............#.....#............................#............................................................##................................................................................................................
................................................................................#.#............###..#...........................#.#.................................................................##................................##........................................................................
.................................................................................##...............#.##..........................#.#.................................................................##.................................#...........#............................................................
...............................................................................................####..#........................###.##.................................................................................................#............#.#...........................................................
..........................................................................................##...#...##........................#.......................................................................................................##..........#...#..##......................................................
..........................................................................................##....###...........................###.##..............................................................##.....................................##......#..#...##......................................................
..................................................................................................#.......##....................#.##..............................................................##.....##...............................#......#..#...........................................................
..................................................................................................#.##...#.#.....#.#.....................................................................................##............................###.......#.#............................................................
.................................................................................................##.#....#........##......#............................................................................................................#..................#.....................................................
....................................................................................................#..##.####....#........##........................#...................................................................................................#.#....................................................
....................................................................................................#.#.#.#..#............##.............#.#.......###............................##......................................................................#.....................................................
..............................................................................##.........##......##.#.#.#.#.............................#..#......#...............................##.....##................................................................###..................................................
...............................................................................##........#.......##.#.#.##..............................#..#......##.....................................##..................................................................#..................................................
..............................................................................#...........###........#.................................#...#..........##........................................................................................................................................................
............................................................................................#...........................................#.#............#........................................................................................................................................................
..................................................................................................................##.....................#...........#.................................##.......................................................................................................................
..................................................................................................................#..................................##................................##.......................................................................................................................
................................................................................................................#.#..........................................................................##.................................................................................................................
.........................................................................................................#......##...........................................................................##.................................................................................................................
.......................................................................................................##.##....................................................................................................................................................................................................
.......................................................................................................##.##.............................................................#...#..................................................................................................................................
.......................................................................................................#..##...........................................................#..#.###.................................................................................................................................
........................................................................................................##........................#...................#...................#.#.#..................................................................##.............................................................
................................................................................................................................#.#...................##................#........................................................................##.............................................................
.....................................................##..........................................................................##..................##................##.........................................................................#.............................................................
......................................................#...............................................##................................................................#.#...#.........................................................##.#......###...........................................................
....................................................#..........##......................................#................................................................#.#.............................................................#.##.....#..#...........................................................
....................................................#####.....#.#......##...........................###.................#..........#.#...........................................................................................................##.#.....##....................................................
.........................................................#......#......#............................#...................###........##.....................................................................................................................#.....................................................
......................................................##.#..#........#.#...................................................#........#............##........................##.##........................................................................#.#.....................................................
.....................................................#...............##.................#.................................##.....................#...............#.##....#..#.#.#....###.........#......................................................##......................................................
.....................................................##...#...##.......................#..........................................................###..........###.##....##.#..#.....###.......###..........................................##.....##...........................................................
...................................................##.......#..........................###...........................##.............................#.........#.............#......##.........#.............................................#...#####...........................................................
..................................................#..#.##.###.............#..........................................#.#.......................................###.##.......##.....#..###.....##...................##........................#....#.............................................................
..................................................##.#....................###........................................#...........................................#.#......##..#.#.................##................#.............##......###.....#.............................................................
.....................................................#.......................#...................................................................................#.#.....#..#..##..#...............#................#.#...........##......#.......###......#....................................................
.....................................................##.....................##....................................................................................#.......##.......#...##........#...................##..........................#.#..#...#.#...................................................
....................................................................................................................................##..........#...................................#..#.........##.............................................#.#####....#....................................................
.............................................................................................................................##.....#.#..........##.................................#.#..........................................................##..##.........................................................
.............................................................##..............................................................##.......#.........##.......................................................................##..........#...........#..............................................................
..............................................................#...........#...........................................................##................................................................................#..#.........#....#.....................................................................
...........................................................###...........##.............................................................................................................................................#..#........#....##..##.................................................................
...........................................................#.............#.#.............................................#.............................................................................................#####.........#...#....#.................................................................
......................................................................................##................................#.#.##...................................................................###................##.##...................##..................................................................
...............................................................................#......#.#...............................#.#.#.#..................................................##.............#...#.................#...................###...................................................................
...............................................................................##.......#............................##.#.#.#.#..#...............................................##.................#..................................................##.......................................................
................................................................................##......##...........................#..#..##.####..............................................................##.##............................................##....#.#......................................................
...............................................................................#.......................................##....#....................................................................#..............................................##.....##......................................................
...........................................................................#...#.............................................#.#................................................##..............................................................................................................................
..........................................................................#.#.................................................##.................................................#...................................................................##.........................................................
..........................................................................#..#.#..............................................................................................###............##.......................##..............................#.........................................................
.......................................................................##.#.#.#.#..#..........................................................................................#..............#....................#...##......##...##..............###..........................................................
.......................................................................#..#..##.####............................................................................#.............................###................#.#...........#...#...............#............................................................
.........................................................................##....#.................................................................................#..............................#...............#.#.........###.....###.........................................................................
...............................................................................#.#.............................................................................###..............................................#...........#.........#.........................................................................
................................................................................##.............................................................................................................................##...............................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
..............................................................................................................................................................................#.#...............................................................................................................................
...............................................................................................................................................................................##...............................................................................................................................
...............................................................................................................................................................................#................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
...............................................................................................................................................................................................#................................................................................................................
.............................................................................................................................................................................................#.#................................................................................................................
..............................................................................................................................................................................................##................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
.............................................................................................................................................................................................................#..................................................................................................
..............................................................................................................................................................................................................##................................................................................................
.............................................................................................................................................................................................................##.................................................................................................
................................................................................................................................................................................................................................................................................................................
................................................................................................................................................................................................................................................................................................................
..................................................................................................................................................................................................................##............................................................................................
..................................................................................................................................................................................................................##............................................................................................
0

@ -0,0 +1,112 @@
int sheet1[500][500] = {};
int sheet2[500][500] = {};
int active = 1;
int width;
int height;
int steps;
void read_map() {
width = getint();
height = getint();
// width <= 498, height <= 498
steps = getint();
getch();
int i = 1;
int j = 1;
while (j <= height) {
i = 1;
while (i <= width) {
int get = getch();
if (get == 35) {
sheet1[j][i] = 1;
} else {
sheet1[j][i] = 0;
}
i = i + 1;
}
// line feed
getch();
j = j + 1;
}
}
void put_map() {
int i = 1;
int j = 1;
while (j <= height) {
i = 1;
while (i <= width) {
if (sheet1[j][i] == 1) {
putch(35);
} else {
putch(46);
}
i = i + 1;
}
// line feed
putch(10);
j = j + 1;
}
}
void swap12() {
int i = 1;
int j = 1;
while (j <= height) {
i = 1;
while (i <= width) {
sheet1[j][i] = sheet2[j][i];
i = i + 1;
}
j = j + 1;
}
}
void step(int source[][500], int target[][500]) {
int i = 1;
int j = 1;
while (j <= height) {
i = 1;
while (i <= width) {
int alive_count = source[j - 1][i - 1] + source[j - 1][i] +
source[j - 1][i + 1] + source[j][i - 1] +
source[j][i + 1] + source[j + 1][i - 1] +
source[j + 1][i] + source[j + 1][i + 1];
if (source[j][i] == 1 && alive_count == 2 ) {
target[j][i] = 1;
} else if (alive_count == 3) {
target[j][i] = 1;
} else {
target[j][i] = 0;
}
i = i + 1;
}
j = j + 1;
}
}
int main() {
read_map();
starttime();
while (steps > 0) {
if (active == 1) {
step(sheet1, sheet2);
active = 2;
} else {
step(sheet2, sheet1);
active = 1;
}
steps = steps - 1;
}
stoptime();
if (active == 2) {
swap12();
}
put_map();
return 0;
}

@ -0,0 +1,331 @@
int func(int n) {
int sum = 0;
int i = 200;
int j = 0;
int s[100];
int m = 0;
while (m < 100){
s[m] = 0;
m=m+1;
}
while(j < n) {
if (i > 1){
s[1] = 1;
if (i > 2){
s[2] = 2;
if (i > 3){
s[3] = 3;
if (i > 4){
s[4] = 4;
if (i > 5){
s[5] = 5;
if (i > 6){
s[6] = 6;
if (i > 7){
s[7] = 7;
if (i > 8){
s[8] = 8;
if (i > 9){
s[9] = 9;
if (i > 10){
s[10] = 10;
if (i > 11){
s[11] = 11;
if (i > 12){
s[12] = 12;
if (i > 13){
s[13] = 13;
if (i > 14){
s[14] = 14;
if (i > 15){
s[15] = 15;
if (i > 16){
s[16] = 16;
if (i > 17){
s[17] = 17;
if (i > 18){
s[18] = 18;
if (i > 19){
s[19] = 19;
if (i > 20){
s[20] = 20;
if (i > 21){
s[21] = 21;
if (i > 22){
s[22] = 22;
if (i > 23){
s[23] = 23;
if (i > 24){
s[24] = 24;
if (i > 25){
s[25] = 25;
if (i > 26){
s[26] = 26;
if (i > 27){
s[27] = 27;
if (i > 28){
s[28] = 28;
if (i > 29){
s[29] = 29;
if (i > 30){
s[30] = 30;
if (i > 31){
s[31] = 31;
if (i > 32){
s[32] = 32;
if (i > 33){
s[33] = 33;
if (i > 34){
s[34] = 34;
if (i > 35){
s[35] = 35;
if (i > 36){
s[36] = 36;
if (i > 37){
s[37] = 37;
if (i > 38){
s[38] = 38;
if (i > 39){
s[39] = 39;
if (i > 40){
s[40] = 40;
if (i > 41){
s[41] = 41;
if (i > 42){
s[42] = 42;
if (i > 43){
s[43] = 43;
if (i > 44){
s[44] = 44;
if (i > 45){
s[45] = 45;
if (i > 46){
s[46] = 46;
if (i > 47){
s[47] = 47;
if (i > 48){
s[48] = 48;
if (i > 49){
s[49] = 49;
if (i > 50){
s[50] = 50;
if (i > 51){
s[51] = 51;
if (i > 52){
s[52] = 52;
if (i > 53){
s[53] = 53;
if (i > 54){
s[54] = 54;
if (i > 55){
s[55] = 55;
if (i > 56){
s[56] = 56;
if (i > 57){
s[57] = 57;
if (i > 58){
s[58] = 58;
if (i > 59){
s[59] = 59;
if (i > 60){
s[60] = 60;
if (i > 61){
s[61] = 61;
if (i > 62){
s[62] = 62;
if (i > 63){
s[63] = 63;
if (i > 64){
s[64] = 64;
if (i > 65){
s[65] = 65;
if (i > 66){
s[66] = 66;
if (i > 67){
s[67] = 67;
if (i > 68){
s[68] = 68;
if (i > 69){
s[69] = 69;
if (i > 70){
s[70] = 70;
if (i > 71){
s[71] = 71;
if (i > 72){
s[72] = 72;
if (i > 73){
s[73] = 73;
if (i > 74){
s[74] = 74;
if (i > 75){
s[75] = 75;
if (i > 76){
s[76] = 76;
if (i > 77){
s[77] = 77;
if (i > 78){
s[78] = 78;
if (i > 79){
s[79] = 79;
if (i > 80){
s[80] = 80;
if (i > 81){
s[81] = 81;
if (i > 82){
s[82] = 82;
if (i > 83){
s[83] = 83;
if (i > 84){
s[84] = 84;
if (i > 85){
s[85] = 85;
if (i > 86){
s[86] = 86;
if (i > 87){
s[87] = 87;
if (i > 88){
s[88] = 88;
if (i > 89){
s[89] = 89;
if (i > 90){
s[90] = 90;
if (i > 91){
s[91] = 91;
if (i > 92){
s[92] = 92;
if (i > 93){
s[93] = 93;
if (i > 94){
s[94] = 94;
if (i > 95){
s[95] = 95;
if (i > 96){
s[96] = 96;
if (i > 97){
s[97] = 97;
if (i > 98){
s[98] = 98;
if (i > 99){
s[99] = 99;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
j=j+1;
int m = 0;
while (m < 100){
sum = sum + s[m];
m=m+1;
}
sum = sum % 65535;
}
return sum;
}
int main() {
starttime();
int loopcount = getint();
putint(func(loopcount));
putch(10);
stoptime();
return 0;
}

@ -0,0 +1,49 @@
//large loop and large array caculate
int COUNT = 500000;
float loop(float x[], float y[], int length) {
int i = 0;
float accumulator = 0.0;
while (i < length) {
accumulator = accumulator + x[i] * y[i];
i = i + 1;
}
return accumulator;
}
int main() {
int i = 0, j = 0;
int len = getint();
float x[2048];
float y[2048];
float total = 0.0;
float a = 0.0;
float b = 1.0;
starttime();
while ( i < COUNT) {
if (i % 10) {
a = 0.0;
b = 1.0;
} else {
a = a + 0.1;
b = b + 0.2;
}
while ( j < len) {
x[j] = a + j;
y[j] = b + j;
j = j + 1;
}
total = total + loop(x, y, len);
i = i + 1;
}
stoptime();
if ((total - 1430318598848512.000000) <=0.000001 && (total - 1430318598848512.000000) >= -0.000001) {
putint(10);
return 0;
}
else {
putint(1);
return 1;
}
}

@ -0,0 +1,48 @@
int COUNT = 500000;
float loop(float x[], float y[], int length) {
int i = 0;
float accumulator = 0.0;
while (i < length) {
accumulator = accumulator + x[i] * y[i];
i = i + 1;
}
return accumulator;
}
int main() {
int i = 0, j = 0;
int len = getint();
float x[4096];
float y[4096];
float total = 0.0;
float a = 0.0;
float b = 1.0;
starttime();
while ( i < COUNT) {
if (i % 10) {
a = 0.0;
b = 1.0;
} else {
a = a + 0.1;
b = b + 0.2;
}
while ( j < len) {
x[j] = a + j;
y[j] = b + j;
j = j + 1;
}
total = total + loop(x, y, len);
i = i + 1;
}
stoptime();
if ((total - 11442437121638400.000000) <=0.000001 && (total - 11442437121638400.000000) >= -0.000001) {
putint(10);
return 0;
}
else {
putint(1);
return 1;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,35 @@
float myabs(float num) {
if(num>0){
return num;
}
if(num<0){
return -num;
}
}
float func(float data, int num) {
if (num < 0) {
return 0;
}
num=num-1;
data = data + func(data, num);
data = data - func(data, num);
return data;
}
int main() {
starttime();
float a = 1.001;
int num = getint();
float res;
float expect = 0.0;
res = func(a, num);
if (res - expect==0)
putch(112);
stoptime();
return 0;
}

@ -0,0 +1,34 @@
float myabs(float num) {
if(num>0){
return num;
}
if(num<0){
return -num;
}
}
float func(float data, int num) {
if (num < 0) {
return 0;
}
num=num-1;
data = data + func(data, num);
data = data - func(data, num);
return data;
}
int main() {
starttime();
float a = 1.001;
int num = getint();
float res;
float expect = 0.0;
res = func(a, num);
if (res - expect==0)
putch(112);
stoptime();
return 0;
}

@ -0,0 +1,34 @@
float myabs(float num) {
if(num>0){
return num;
}
if(num<0){
return -num;
}
}
float func(float data, int num) {
if (num < 0) {
return 0;
}
num=num-1;
data = data + func(data, num);
data = data - func(data, num);
return data;
}
int main() {
starttime();
float a = 1.001;
int num = getint();
float res;
float expect = 1.001;
res = func(a, num);
if (res - expect==0)
putch(112);
stoptime();
return 0;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1,93 @@
int hashmod;
const int maxn = 10000000;
const int maxm = 10000000;
int bucket[maxn];
int head[maxn];
int next[maxm];
int nextvalue[maxm];
int key[maxm];
int value[maxm];
int cnt;
int keys[maxm];
int values[maxm];
int requests[maxm];
int ans[maxm];
int hash(int k){
return k % hashmod;
}
int insert(int k, int v){
int h = hash(k);
if (head[h] == 0){
cnt = cnt + 1;
head[h] = cnt;
key[cnt] = k;
value[cnt] = v;
next[cnt] = 0;
nextvalue[cnt] = 0;
return 0;
}
int p = head[h];
while (p != 0){
if (key[p] == k){
cnt = cnt + 1;
nextvalue[cnt] = nextvalue[p];
nextvalue[p] = cnt;
value[cnt] = v;
return 1;
}
p = next[p];
}
cnt = cnt + 1;
next[cnt] = head[h];
head[h] = cnt;
key[cnt] = k;
value[cnt] = v;
nextvalue[cnt] = 0;
return 0;
}
int reduce(int k){
int h = hash(k);
int p = head[h];
while (p != 0){
if (key[p] == k){
int ret = 0;
int x = p;
while (x != 0){
ret = ret + value[x];
x = nextvalue[x];
}
return ret;
}
p = next[p];
}
return 0;
}
int main(){
hashmod = getint();
int ks = getarray(keys);
int vs = getarray(values);
int ms = getarray(requests);
starttime();
int i = 0;
while (i < ks){
insert(keys[i], values[i]);
i = i + 1;
}
i = 0;
while (i < ms){
ans[i] = reduce(requests[i]);
i = i + 1;
}
stoptime();
putarray(ms, ans);
return 0;
}

@ -0,0 +1,60 @@
int x[600][600][600];
int y[600][600][600];
int main()
{
int i,j,k;
int f;
int N;
N = getint ();
f = getint ();
starttime();
i = 0;
j = 0;
k = 0;
while (i<N) {
j = 0;
k = 0;
while (j<N) {
k = 0;
while (k<N) {
x[i][j][k] = 1;
y[i][j][k] = 0;
k = k + 1;
}
j = j + 1;
}
i = i + 1;
}
i = 1;
j = 1;
k = 1;
while (i<N - 1) {
j = 1;
k = 1;
while (j<N - 1) {
k = 1;
while (k<N - 1) {
x[i][j][k] = ( x[i-1][j][k] + x[i+1][j][k] + x[i][j-1][k] +
x[i][j+1][k] + x[i][j][k-1] + x[i][j][k+1] ) / f;
k = k + 1;
}
j = j + 1;
}
i = i + 1;
}
stoptime();
putarray (N, x[0][0]);
putarray (N, x[N/2][N/2]);
putarray (N, x[i-1][j-1]);
return 0;
}

@ -0,0 +1,4 @@
400: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
400: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 1
400: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 1
0

@ -0,0 +1,4 @@
300: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
300: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 1
300: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 1
0

@ -0,0 +1,60 @@
int x[600][600][600];
int y[600][600][600];
int main()
{
int i,j,k;
int f;
int N;
N = getint ();
f = getint ();
starttime();
i = 0;
j = 0;
k = 0;
while (i<N) {
j = 0;
k = 0;
while (j<N) {
k = 0;
while (k<N) {
x[i][j][k] = 1;
y[i][j][k] = 0;
k = k + 1;
}
j = j + 1;
}
i = i + 1;
}
i = 1;
j = 1;
k = 1;
while (i<N - 1) {
j = 1;
k = 1;
while (j<N - 1) {
k = 1;
while (k<N - 1) {
x[i][j][k] = ( x[i-1][j][k] + x[i+1][j][k] + x[i][j-1][k] +
x[i][j+1][k] + x[i][j][k-1] + x[i][j][k+1] ) / f;
k = k + 1;
}
j = j + 1;
}
i = i + 1;
}
stoptime();
putarray (N, x[0][0]);
putarray (N, x[N/2][N/2]);
putarray (N, x[i-1][j-1]);
return 0;
}

@ -0,0 +1,51 @@
int matrix[20000000];
int a[100000];
int transpose(int n, int matrix[], int rowsize){
int colsize = n / rowsize;
int i = 0;
int j = 0;
while (i < colsize){
j = 0;
while (j < rowsize){
if (i < j){
j = j + 1;
continue;
}
int curr = matrix[i * rowsize + j];
matrix[j * colsize + i] = matrix[i * rowsize + j];
matrix[i * rowsize + j] = curr;
j = j + 1;
}
i = i + 1;
}
return -1;
}
int main(){
int n = getint();
int len = getarray(a);
starttime();
int i = 0;
while (i < n){
matrix[i] = i;
i = i + 1;
}
i = 0;
while (i < len){
transpose(n, matrix, a[i]);
i = i + 1;
}
int ans = 0;
i = 0;
while (i < len){
ans = ans + i * i * matrix[i];
i = i + 1;
}
if (ans < 0) ans = -ans;
stoptime();
putint(ans);
putch(10);
return 0;
}

@ -0,0 +1,8 @@
//test domain of global var define and local define
int a = 3;
int b = 5;
int main(){
int a = 5;
return a + b;
}

@ -0,0 +1,9 @@
//test array define
int main(){
int a[4][2] = {};
int b[4][2] = {1, 2, 3, 4, 5, 6, 7, 8};
int c[4][2] = {{1, 2}, {3, 4}, {5, 6}, {7, 8}};
int d[4][2] = {1, 2, {3}, {5}, 7 , 8};
int e[4][2] = {{d[2][1], c[2][1]}, {3, 4}, {5, 6}, {7, 8}};
return e[3][1] + e[0][0] + e[0][1] + a[2][0];
}

@ -0,0 +1,11 @@
int a;
int func(int p){
p = p - 1;
return p;
}
int main(){
int b;
a = 10;
b = func(a);
return b;
}

@ -0,0 +1,7 @@
//test add
int main(){
int a, b;
a = 10;
b = -1;
return a + b;
}

@ -0,0 +1,7 @@
//test sub
const int a = 10;
int main(){
int b;
b = 2;
return b - a;
}

@ -0,0 +1,5 @@
//test divc
const int a = 10;
int main(){
return a / 5;
}

@ -0,0 +1,18 @@
// test if-{if-else}
int if_ifElse_() {
int a;
a = 5;
int b;
b = 10;
if(a == 5){
if (b == 10)
a = 25;
else
a = a + 15;
}
return (a);
}
int main(){
return (if_ifElse_());
}

@ -0,0 +1,55 @@
int g;
int h;
int f;
int e;
int EightWhile() {
int a;
a = 5;
int b;
int c;
b = 6;
c = 7;
int d;
d = 10;
while (a < 20) {
a = a + 3;
while(b < 10){
b = b + 1;
while(c == 7){
c = c - 1;
while(d < 20){
d = d + 3;
while(e > 1){
e = e-1;
while(f > 2){
f = f -2;
while(g < 3){
g = g +10;
while(h < 10){
h = h + 8;
}
h = h-1;
}
g = g- 8;
}
f = f + 1;
}
e = e + 1;
}
d = d - 1;
}
c = c + 1;
}
b = b - 2;
}
return (a + (b + d) + c)-(e + d - g + h);
}
int main() {
g = 1;
h = 2;
e = 4;
f = 6;
return EightWhile();
}

@ -0,0 +1,16 @@
//test continue
int main(){
int i;
i = 0;
int sum;
sum = 0;
while(i < 100){
if(i == 50){
i = i + 1;
continue;
}
sum = sum + i;
i = i + 1;
}
return sum;
}

@ -0,0 +1,25 @@
// test while-if
int whileIf() {
int a;
a = 0;
int b;
b = 0;
while (a < 100) {
if (a == 5) {
b = 25;
}
else if (a == 10) {
b = 42;
}
else {
b = a * 2;
}
a = a + 1;
}
return (b);
}
int main(){
return (whileIf());
}

@ -0,0 +1,25 @@
int deepWhileBr(int a, int b) {
int c;
c = a + b;
while (c < 75) {
int d;
d = 42;
if (c < 100) {
c = c + d;
if (c > 99) {
int e;
e = d * 2;
if (1 == 1) {
c = e * 2;
}
}
}
}
return (c);
}
int main() {
int p;
p = 2;
return deepWhileBr(p, p);
}

@ -0,0 +1,9 @@
//test the priority of add and mul
int main(){
int a, b, c, d;
a = 10;
b = 4;
c = 2;
d = 2;
return c + a * b - d;
}

@ -0,0 +1,9 @@
//test the priority of add and mul
int main(){
int a, b, c, d;
a = 10;
b = 4;
c = 2;
d = 2;
return (c + a) * (b - d);
}

@ -0,0 +1,7 @@
//test the priority of unary operator and binary operator
int main(){
int a, b;
a = 10;
b = 30;
return a - -5 + b + -5;
}

@ -0,0 +1,19 @@
int a;
int b;
int c;
int d;
int e;
int main()
{
a=getint();
b=getint();
c=getint();
d=getint();
e=getint();
int flag=0;
if(a-b*c!=d-a/c||a*b/c==e+d||a+b+c==d+e)
{
flag=1;
}
return flag;
}

@ -0,0 +1,14 @@
int main() {
int a, b;
a = 070;
b = 0x4;
a = a - - 4 + + b;
if (+-!!!a) {
a = - - -1;
}
else {
a = 0 + + b;
}
putint(a);
return 0;
}

@ -0,0 +1,15 @@
int a;
int b;
int main()
{
a=getint();
b=getint();
int c;
if (a==b&&a!=3) {
c = 1;
}
else {
c = 0;
}
return c;
}

@ -0,0 +1,6 @@
// test hexadecimal define
int main(){
int a;
a = 0xf;
return a;
}

@ -0,0 +1,7 @@
//test add of hex and oct
int main(){
int a, b;
a = 0xf;
b = 0xc;
return a + b + 075;
}

@ -0,0 +1,18 @@
// Use complex expression in assign structure
int main () {
int a;
int b;
int c;
int d;
int result;
a = 5;
b = 5;
c = 1;
d = -2;
result = (d * 1 / 2) + (a - b) - -(c + 3) % 2;
putint(result);
result = ((d % 2 + 67) + -(a - b) - -((c + 2) % 2));
result = result + 3;
putint(result);
return 0;
}

@ -0,0 +1,21 @@
// Use complex expression in if structure
int main () {
int a;
int b;
int c;
int d;
int result;
a = 5;
b = 5;
c = 1;
d = -2;
result = 2;
if ((d * 1 / 2) < 0 || (a - b) != 0 && (c + 3) % 2 != 0) {
putint(result);
}
if ((d % 2 + 67) < 0 || (a - b) != 0 && (c + 2) % 2 != 0) {
result = 4;
putint(result);
}
return 0;
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save