add functional test cases

main
wqz 3 years ago
parent 1568042d62
commit 53dcd83a00

@ -0,0 +1,3 @@
int main(){
return 3;
}

@ -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,8 @@
//test local var define
int main(){
int a, b0, _c;
a = 1;
b0 = 2;
_c = 3;
return b0 + _c;
}

@ -0,0 +1,4 @@
int a[10][10];
int main(){
return 0;
}

@ -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,9 @@
int main(){
const int a[4][2] = {{1, 2}, {3, 4}, {}, 7};
const int N = 3;
int b[4][2] = {};
int c[4][2] = {1, 2, 3, 4, 5, 6, 7, 8};
int d[N + 1][2] = {1, 2, {3}, {5}, a[3][0], 8};
int e[4][2][1] = {{d[2][1], {c[2][1]}}, {3, 4}, {5, 6}, {7, 8}};
return e[3][1][0] + e[0][0][0] + e[0][1][0] + d[3][0];
}

@ -0,0 +1,6 @@
//test const gloal var define
const int a = 10, b = 5;
int main(){
return b;
}

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

@ -0,0 +1,5 @@
const int a[5]={0,1,2,3,4};
int main(){
return a[4];
}

@ -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,8 @@
int defn(){
return 4;
}
int main(){
int a=defn();
return a;
}

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

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

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

@ -0,0 +1,6 @@
//test subc
int main(){
int a;
a = 10;
return a - 2;
}

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

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

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

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

@ -0,0 +1,6 @@
//test mod
int main(){
int a;
a = 10;
return a / 3;
}

@ -0,0 +1,6 @@
//test rem
int main(){
int a;
a = 10;
return a % 3;
}

@ -0,0 +1,25 @@
// test if-else-if
int ifElseIf() {
int a;
a = 5;
int b;
b = 10;
if(a == 6 || b == 0xb) {
return a;
}
else {
if (b == 10 && a == 1)
a = 25;
else if (b == 10 && a == -5)
a = a + 15;
else
a = -+a;
}
return a;
}
int main(){
putint(ifElseIf());
return 0;
}

@ -0,0 +1,18 @@
// test if-if-else
int ififElse() {
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 (ififElse());
}

@ -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,18 @@
// test if-{if}-else
int if_if_Else() {
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_if_Else());
}

@ -0,0 +1,31 @@
int get_one(int a) {
return 1;
}
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 (get_one(0) == 1) {
c = e * 2;
}
}
}
}
return (c);
}
int main() {
int p;
p = 2;
p = deepWhileBr(p, p);
putint(p);
return 0;
}

@ -0,0 +1,18 @@
int doubleWhile() {
int i;
i = 5;
int j;
j = 7;
while (i < 100) {
i = i + 30;
while(j < 100){
j = j + 6;
}
j = j - 100;
}
return (j);
}
int main() {
return doubleWhile();
}

@ -0,0 +1,31 @@
int FourWhile() {
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;
}
d = d - 1;
}
c = c + 1;
}
b = b - 2;
}
return (a + (b + d) + c);
}
int main() {
return FourWhile();
}

@ -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,15 @@
//test break
int main(){
int i;
i = 0;
int sum;
sum = 0;
while(i < 100){
if(i == 50){
break;
}
sum = sum + i;
i = i + 1;
}
return sum;
}

@ -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,23 @@
int ifWhile() {
int a;
a = 0;
int b;
b = 3;
if (a == 5) {
while(b == 2){
b = b + 2;
}
b = b + 25;
}
else
while (a < 5) {
b = b * 2;
a = a + 1;
}
return (b);
}
int main(){
return (ifWhile());
}

@ -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,11 @@
const int N = -1;
int arr[N + 2 * 4 - 99 / 99] = {1, 2, 33, 4, 5, 6};
int main() {
int i = 0, sum = 0;
while (i < 6) {
sum = sum + arr[i];
i = i + 1;
}
return sum;
}

@ -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,15 @@
int a = 1;
int b = 0;
int c = 1;
int d = 2;
int e = 4;
int main()
{
int flag=0;
if(a * b / c == e + d && a * (a + b) + c <= d + e || a - (b * c) == d - a / c)
{
flag=1;
}
putint(flag);
return flag;
}

@ -0,0 +1,11 @@
int main() {
int a;
a = 10;
if (+-!!!a) {
a = - - -1;
}
else {
a = 0;
}
return a;
}

@ -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,5 @@
int main() {
int a = 10;
;
return a * 2 + 1;
}

@ -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,13 @@
int k;
const int n = 10;
int main () {
int i = 0;
k = 1;
while (i <= n - 1) {
i = i + 1;
k + 1;
k = k + k;
}
putint(k);
return k;
}

@ -0,0 +1,12 @@
//test comment
int main(){
int a;
a = 5;
//int b = 4;
//a = b + a;
/*/*
b = 1;
// b = 2
*/
return a;
}

@ -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;
}

@ -0,0 +1,21 @@
int g = 0;
int func(int n) {
g = g + n;
putint(g);
return g;
}
int main() {
int i;
i = getint();
if (i > 10 && func(i)) i = 1; else i = 0;
i = getint();
if (i > 11 && func(i)) i = 1; else i = 0;
i = getint();
if (i <= 99 || func(i)) i = 1; else i = 0;
i = getint();
if (i <= 100 || func(i)) i = 1; else i = 0;
if (!func(99) && func(100)) i = 1; else i = 0;
return 0;
}

@ -0,0 +1,44 @@
int a, b, d;
int set_a(int val) { a = val; return a; }
int set_b(int val) { b = val; return b; }
int set_d(int val) { d = val; return d; }
int main()
{
a = 2; b = 3;
if (set_a(0) && set_b(1)) {}
putint(a); putch(32);
putint(b); putch(32);
a = 2; b = 3;
if (set_a(0) && set_b(1)) ;
putint(a); putch(32);
putint(b); putch(10);
const int c = 1;
d = 2;
if (c >= 1 && set_d(3)) ;
putint(d); putch(32);
if (c <= 1 || set_d(4)) {}
putint(d); putch(10);
if (16 >= (3 - (2 + 1))) { putch(65); }
if ((25 - 7) != (36 - 6 * 3)) putch(66);
if (1 < 8 != 7 % 2) { putch(67); }
if (3 > 4 == 0) { putch(68); }
if (1 == 0x66 <= 077) putch(69);
if (5 - 6 == -!0) putch(70);
putch(10);
int i0 = 0, i1 = 1, i2 = 2, i3 = 3, i4 = 4;
while (i0 && i1) putch(32);
if (i0 || i1) putch(67);
if (i0 >= i1 || i1 <= i0) putch(72);
if (i2 >= i1 && i4 != i3) { putch(73); }
if (i0 == !i1 && i3 < i3 || i4 >= i4) { putch(74); }
if (i0 == !i1 || i3 < i3 && i4 >= i4) putch(75);
putch(10);
return 0;
}

@ -0,0 +1,27 @@
int a = 7;
int func() {
int b = a;
int a = 1;
if (a == b) {
a = a + 1;
return 1;
}
else
return 0;
}
int main() {
int result = 0;
int i = 0;
while (i < 100) {
if (func() == 1)
result = result + 1;
i = i + 1;
}
if (result < 100)
putint(1);
else
putint(0);
return 0;
}

@ -0,0 +1,26 @@
int k;
int main() {
k = 3389;
if (k < 10000) {
k = k + 1;
int k = 112;
while (k > 10) {
k = k - 88;
if (k < 1000) {
int g = 9;
{
int l = 11;
{
g = 10;
k = k - g;
int g = 11;
k = k + g + l;
}
}
}
}
putint(k);
}
return k;
}

@ -0,0 +1,54 @@
int b = 5;
int c[4] = {6, 7, 8, 9};
int main()
{
int a;
a = 1;
{
int a;
a = 2;
{
a = 3;
putint(a);
}
putint(a);
}
putint(a); putch(10);
while (a < 5) {
int a = 0;
a = a + 1;
if (a)
break;
}
putint(a); putch(10);
{
{
{
{}
}
c[2] = 1;
{
int c[2][8] = {{0, 9}, 8, 3};
}
}
}
{
int b = 2;
if (c[2]) {
int c[7][1][5] = {{}, {}, {2, 1, 8}, {{}}};
putint(c[b][0][0]);
putint(c[b][0][1]);
putint(c[b][0][2]);
}
}
putch(10);
putint(b); putch(10);
putint(c[0]); putint(c[1]); putint(c[2]); putint(c[3]); putch(10);
return 0;
}

@ -0,0 +1,41 @@
int n;
int bubblesort(int arr[])
{
int i;
int j;
i =0;
while(i < n-1){
// Last i elements are already in place
j = 0;
while(j < n-i-1){
if (arr[j] > arr[j+1]) {
// swap(&arr[j], &arr[j+1]);
int tmp;
tmp = arr[j+1];
arr[j+1] = arr[j];
arr[j] = tmp;
}
j = j + 1;
}
i = i + 1;
}
return 0;
}
int main(){
n = 10;
int a[10];
a[0]=4;a[1]=3;a[2]=9;a[3]=2;a[4]=0;
a[5]=1;a[6]=6;a[7]=5;a[8]=7;a[9]=8;
int i;
i = bubblesort(a);
while (i < n) {
int tmp;
tmp = a[i];
putint(tmp);
tmp = 10;
putch(tmp);
i = i + 1;
}
return 0;
}

@ -0,0 +1,39 @@
int n;
int insertsort(int a[])
{
int i;
i = 1;
while(i<n)
{
int temp;
temp=a[i];
int j;
j=i-1;
while(j>-1&&temp<a[j])
{
a[j+1]=a[j];
j = j - 1;
}
a[j+1]=temp;
i = i + 1;
}
return 0;
}
int main(){
n = 10;
int a[10];
a[0]=4;a[1]=3;a[2]=9;a[3]=2;a[4]=0;
a[5]=1;a[6]=6;a[7]=5;a[8]=7;a[9]=8;
int i;
i = insertsort(a);
while (i < n) {
int tmp;
tmp = a[i];
putint(tmp);
tmp = 10;
putch(tmp);
i = i + 1;
}
return 0;
}

@ -0,0 +1,66 @@
int n;
int QuickSort(int arr[], int low, int high)
{
if (low < high)
{
int i;
i = low;
int j;
j = high;
int k;
k = arr[low];
while (i < j)
{
while(i < j && arr[j] > k - 1)
{
j = j - 1;
}
if(i < j)
{
arr[i] = arr[j];
i = i + 1;
}
while(i < j && arr[i] < k)
{
i = i + 1;
}
if(i < j)
{
arr[j] = arr[i];
j = j - 1;
}
}
arr[i] = k;
int tmp;
tmp = i - 1;
tmp = QuickSort(arr, low, tmp);
tmp = i + 1;
tmp = QuickSort(arr, tmp, high);
}
return 0;
}
int main(){
n = 10;
int a[10];
a[0]=4;a[1]=3;a[2]=9;a[3]=2;a[4]=0;
a[5]=1;a[6]=6;a[7]=5;a[8]=7;a[9]=8;
int i;
i = 0;
int tmp;
tmp = 9;
i = QuickSort(a, i, tmp);
while (i < n) {
int tmp;
tmp = a[i];
putint(tmp);
tmp = 10;
putch(tmp);
i = i + 1;
}
return 0;
}

@ -0,0 +1,49 @@
int n;
int select_sort(int A[],int n)
{
int i;
int j;
int min;
i =0;
while(i < n-1)
{
min=i;//
j = i + 1;
while(j < n)
{
if(A[min]>A[j])
{
min=j;
}
j=j+1;
}
if(min!=i)
{
int tmp;
tmp = A[min];
A[min] = A[i];
A[i] = tmp;
}
i = i + 1;
}
return 0;
}
int main(){
n = 10;
int a[10];
a[0]=4;a[1]=3;a[2]=9;a[3]=2;a[4]=0;
a[5]=1;a[6]=6;a[7]=5;a[8]=7;a[9]=8;
int i;
i = 0;
i = select_sort(a, n);
while (i < n) {
int tmp;
tmp = a[i];
putint(tmp);
tmp = 10;
putch(tmp);
i = i + 1;
}
return 0;
}

@ -0,0 +1,65 @@
int n;
int swap (int array[], int i, int j){
int temp;
temp = array[i];
array[i] = array[j];
array[j] = temp;
return 0;
}
int heap_ajust(int arr[], int start, int end) {
int dad;
dad = start;
int son;
son = dad * 2 + 1;
while (son < end + 1) { //
if (son < end && arr[son] < arr[son + 1])
son = son + 1;
if (arr[dad] > arr[son])
return 0;
else {
dad = swap(arr,dad,son);
dad = son;
son = dad * 2 + 1;
}
}
return 0;
}
int heap_sort(int arr[], int len) {
int i;
int tmp;
i = len / 2 - 1;
while ( i > -1) {
tmp = len - 1;
tmp = heap_ajust(arr, i, tmp);
i = i - 1;
}
i = len - 1;
while ( i > 0) {
int tmp0;
tmp0 = 0;
tmp = swap(arr,tmp0,i);
tmp = i - 1;
tmp = heap_ajust(arr, tmp0, tmp);
i = i-1;
}
return 0;
}
int main(){
n = 10;
int a[10];
a[0]=4;a[1]=3;a[2]=9;a[3]=2;a[4]=0;
a[5]=1;a[6]=6;a[7]=5;a[8]=7;a[9]=8;
int i;
i = 0;
i = heap_sort(a, n);
while (i < n) {
int tmp;
tmp = a[i];
putint(tmp);
tmp = 10;
putch(tmp);
i = i + 1;
}
return 0;
}

@ -0,0 +1,53 @@
int n;
int counting_sort(int ini_arr[], int sorted_arr[], int n) {
int count_arr[10];
int i;
int j;
int k;
k = 0;
i = 0;
j = 0;
while(k < 10){
count_arr[k] = 0;
k = k + 1;
}
while(i < n)
{
count_arr[ini_arr[i]] = count_arr[ini_arr[i]] + 1;
i = i + 1;
}
k = 1;
while(k < 10){
count_arr[k] = count_arr[k] + count_arr[k - 1];
k = k + 1;
}
j = n;
while( j > 0){
count_arr[ini_arr[j - 1]] = count_arr[ini_arr[j - 1]] - 1;
sorted_arr[count_arr[ini_arr[j - 1]]] = ini_arr[j - 1];
j = j - 1;
}
return 0;
}
int main(){
n = 10;
int a[10];
a[0]=4;a[1]=3;a[2]=9;a[3]=2;a[4]=0;
a[5]=1;a[6]=6;a[7]=5;a[8]=7;a[9]=8;
int i;
i = 0;
int b[10];
i = counting_sort(a, b, n);
while (i < n) {
int tmp;
tmp = b[i];
putint(tmp);
tmp = 10;
putch(tmp);
i = i + 1;
}
return 0;
}

@ -0,0 +1,11 @@
97
-10525 -9882 48155 -22162 -38879 52218 -44913 14799 -52541 19859
23040 38767 -39850 -2221 -63865 51868 64903 -3812 -58581 -14684
-29113 12117 -32032 -58451 -59283 -24783 -10753 -18185 28370 7266
760 30956 -35818 -52888 -37486 21562 14967 53534 46231 -46019
-46994 -62145 24886 18009 63111 -14203 40779 51479 36163 14992
57399 -58381 5335 -38236 4245 -33049 33608 -63687 37320 -32676
6602 40444 1715 11292 2406 16023 1996 -60066 -52763 -16559
53676 22077 57606 46802 -2033 -64412 -58092 61266 59389 -38805
1155 59786 35700 52562 9161 -2723 -57451 46501 -2730 38395
-2556 -38481 52802 -47314 -21799 -18640 60818

@ -0,0 +1,47 @@
int buf[2][100];
// sort [l, r)
void merge_sort(int l, int r)
{
if (l + 1 >= r)
return;
int mid = (l + r) / 2;
merge_sort(l, mid);
merge_sort(mid, r);
int i = l, j = mid, k = l;
while (i < mid && j < r) {
if (buf[0][i] < buf[0][j]) {
buf[1][k] = buf[0][i];
i = i + 1;
} else {
buf[1][k] = buf[0][j];
j = j + 1;
}
k = k + 1;
}
while (i < mid) {
buf[1][k] = buf[0][i];
i = i + 1;
k = k + 1;
}
while (j < r) {
buf[1][k] = buf[0][j];
j = j + 1;
k = k + 1;
}
while (l < r) {
buf[0][l] = buf[1][l];
l = l + 1;
}
}
int main()
{
int n = getarray(buf[0]);
merge_sort(0, n);
putarray(n, buf[0]);
return 0;
}

@ -0,0 +1,10 @@
2 2
3 1
4 2
4 4
1 2
2 3
2 1
3 2
3 4
3 1

@ -0,0 +1,82 @@
int array[110];
int n;
void init(int n) {
int i = 1;
while (i <= n * n + 1) {
array[i] = -1;
i = i + 1;
}
}
int findfa(int a) {
if (array[a] == a)
return a;
else {
array[a] = findfa(array[a]);
return array[a];
}
}
void mmerge(int a, int b) {
int m = findfa(a);
int n = findfa(b);
if (m != n) array[m] = n;
}
int main() {
int t, m;
int a, b;
t = 1;
while (t) {
t = t - 1;
n = 4;
m = 10;
int i = 0;
int flag = 0;
init(n);
int k = n * n + 1;
while (i < m) {
a = getint();
b = getint();
if (!flag) {
int loc = n * (a - 1) + b;
array[loc] = loc;
if (a == 1) {
array[0] = 0;
mmerge(loc, 0);
}
if (a == n) {
array[k] = k;
mmerge(loc, k);
}
if (b < n && array[loc + 1] != -1) {
mmerge(loc, loc + 1);
}
if (b > 1 && array[loc - 1] != -1) {
mmerge(loc, loc - 1);
}
if (a < n && array[loc + n] != -1) {
mmerge(loc, loc + n);
}
if (a > 1 && array[loc - n] != -1) {
mmerge(loc, loc - n);
}
if (array[0] != -1 && array[k] != -1 && findfa(0) == findfa(k)) {
flag = 1;
int tmp = i + 1;
putint(tmp);
putch(10);
}
}
i = i + 1;
}
if (!flag) {
putint(-1);
putch(10);
}
}
return 0;
}

@ -0,0 +1,65 @@
const int len = 20;
int main()
{
int i, j, t, n, temp;
int mult1[len] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
int mult2[len] = {2, 3, 4, 2, 5, 7 ,9 ,9, 0, 1, 9, 8, 7, 6, 4, 3, 2, 1, 2, 2};
int len1 = len;
int len2 = len;
int c1[len + 5];
int c2[len + 5];
int result[len * 2] = {};
i = 0;
while (i < len1) {
c1[i] = mult1[i];
i = i + 1;
}
i = 0;
while (i < len2) {
c2[i] = mult2[i];
i = i + 1;
}
n = len1 + len2 - 1;
i = 0;
while (i <= n) {
result[i]=0;
i = i + 1;
}
temp=0;
i = len2 - 1;
while (i > -1) {
t = c2[i];
j = len1 - 1;
while (j > -1) {
temp = result[n] + t * c1[j];
if(temp >= 10) {
result[n] = (temp);
result[n-1] = result[n-1] + temp / 10;
}
else
result[n] = temp;
j = j - 1;
n = n - 1;
}
n = n + len1 - 1;
i = i - 1;
}
if(result[0] != 0)
putint(result[0]);
i = 1;
while (i <= len1 + len2 - 1) {
putint(result[i]);
i = i + 1;
}
return 0;
}

@ -0,0 +1 @@
(4 - (3 - 5) * 2 + 100) % (2^3 - 1) / 2 + 1

@ -0,0 +1,184 @@
int ints[10000];
int intt;
int chas[10000];
int chat;
int i=0, ii=1;
int c;
int get[10000];
int get2[10000];
int isdigit(int x) {
if (x >= 48 && x <= 57)
return 1;
return 0;
}
int power(int b, int a) {
int result = 1;
while (a != 0) {
result = result * b;
a = a - 1;
}
return result;
}
int getstr(int get[]) {
int x = getch();
int length = 0;
while (x != 13 && x != 10) {
get[length] = x;
length = length + 1;
x = getch();
}
return length;
}
void intpush(int x)
{
intt = intt + 1;
ints[intt] = x;
}
void chapush(int x)
{
chat = chat + 1;
chas[chat] = x;
}
int intpop()
{
intt = intt - 1;
return ints[intt + 1];
}
int chapop()
{
chat = chat - 1;
return chas[chat + 1];
}
void intadd(int x)
{
ints[intt] = ints[intt] * 10;
ints[intt] = ints[intt] + x;
}
int find()
{
c = chapop();
get2[ii] = 32;
get2[ii + 1] = c;
ii = ii + 2;
if (chat == 0) return 0;
return 1;
}
int main()
{
intt=0;
chat=0;
int lengets = getstr(get);
while (i < lengets)
{
if (isdigit(get[i]) == 1)
{
get2[ii] = get[i];
ii = ii + 1;
}
else
{
if(get[i] == 40) chapush(40);
if(get[i] == 94) chapush(94);
if(get[i] == 41)
{
c = chapop();
while (c != 40)
{
get2[ii] = 32;
get2[ii + 1]=c;
ii = ii + 2;
c = chapop();
}
}
if (get[i] == 43)
{
while (chas[chat] == 43 || chas[chat] == 45 || chas[chat] == 42 || chas[chat] == 47 || chas[chat] == 37 || chas[chat] == 94)
{
if (find()==0)break;
}
chapush(43);
}
if (get[i] == 45)
{
while (chas[chat] == 43 || chas[chat] == 45 ||chas[chat] == 42 || chas[chat] == 47 || chas[chat] == 37 || chas[chat] == 94)
{
if(find()==0)break;
}
chapush(45);
}
if(get[i] == 42)
{
while (chas[chat] == 42 || chas[chat] == 47 ||chas[chat] == 37 || chas[chat] == 94)
{
if (find()==0)break;
}
chapush(42);
}
if (get[i] == 47)
{
while (chas[chat] == 42 || chas[chat] == 47 || chas[chat] == 37 || chas[chat] == 94)
{
if (find()==0)break;
}
chapush(47);
}
if (get[i] == 37)
{
while (chas[chat] == 42 || chas[chat] == 47 || chas[chat] == 37 || chas[chat] == 94)
{
if (find()==0)break;
}
chapush(37);
}
get2[ii] = 32;
ii = ii + 1;
}
i = i + 1;
}
while(chat > 0)
{
int c = chapop();
get2[ii] = 32;
get2[ii + 1]=c;
ii = ii + 2;
}
get2[ii]= 64;
i = 1;
while (get2[i] != 64)
{
if (get2[i] == 43 || get2[i] == 45 || get2[i] == 42 || get2[i] == 47 || get2[i] == 37 || get2[i] == 94)
{
int a=intpop();int b=intpop();int c;
if (get2[i] == 43) c = a + b;
if (get2[i] == 45) c = b - a;
if (get2[i] == 42) c = a * b;
if (get2[i] == 47) c = b / a;
if (get2[i] == 37) c = b % a;
if (get2[i] == 94) c = power(b,a);
intpush(c);
}
else
{
if(get2[i] != 32)
{
intpush(get2[i] - 48);
ii=1;
while(get2[i+ii] != 32)
{
intadd(get2[i+ii] - 48);
ii = ii + 1;
}
i = i + ii-1;
}
}
i = i + 1;
}
putint(ints[1]);
return 0;
}

@ -0,0 +1,69 @@
const int maxn = 18;
const int mod = 1000000007;
int dp[maxn][maxn][maxn][maxn][maxn][7];
int list[200];
int equal(int a, int b) {
if (a == b)
return 1;
return 0;
}
int dfs(int a, int b, int c, int d, int e, int last){
if(dp[a][b][c][d][e][last] != -1)
return dp[a][b][c][d][e][last];
if(a + b + c + d + e == 0)
return 1;
int ans = 0;
if (a) ans = (ans + (a - equal(last, 2)) * dfs(a - 1, b, c, d, e, 1)) % mod;
if (b) ans = (ans + (b - equal(last, 3)) * dfs(a + 1, b - 1, c, d, e, 2)) % mod;
if (c) ans = (ans + (c - equal(last, 4)) * dfs(a, b + 1, c - 1, d, e, 3)) % mod;
if (d) ans = (ans + (d - equal(last, 5)) * dfs(a, b, c + 1, d - 1, e, 4)) % mod;
if (e) ans = (ans + e * dfs(a, b, c, d + 1, e - 1, 5)) % mod;
dp[a][b][c][d][e][last] = ans % mod;
return dp[a][b][c][d][e][last];
}
int cns[20];
int main(){
int n = getint();
int i = 0;
while (i < maxn) {
int j = 0;
while(j < maxn) {
int k = 0;
while(k < maxn) {
int l = 0;
while (l < maxn) {
int m = 0;
while (m < maxn) {
int h = 0;
while (h < 7) {
dp[i][j][k][l][m][h] = -1;
h = h + 1;
}
m = m + 1;
}
l = l + 1;
}
k = k + 1;
}
j = j + 1;
}
i = i + 1;
}
i = 0;
while (i < n) {
list[i] = getint();
cns[list[i]] = cns[list[i]] + 1;
i = i + 1;
}
int ans = dfs(cns[1], cns[2], cns[3], cns[4], cns[5], 0);
putint(ans);
return ans;
}

@ -0,0 +1,22 @@
int exgcd(int a,int b,int x[],int y[]) {
if(b == 0) {
x[0] = 1;
y[0] = 0;
return a;
}
else {
int r = exgcd(b, a % b, x, y);
int t = x[0];
x[0] = y[0];
y[0] = (t - a / b * y[0]);
return r;
}
}
int main() {
int a = 7, b = 15, x[1] = {1}, y[1] = {1};
exgcd(a, b, x, y);
x[0] = (x[0] % b + b) % b;
putint(x[0]);
return 0;
}

@ -0,0 +1,200 @@
0
3
6
9
12
15
18
21
24
27
30
33
36
39
42
45
48
51
54
57
60
63
66
69
72
75
78
81
84
87
90
93
96
99
102
105
108
111
114
117
120
123
126
129
132
135
138
141
144
147
150
153
156
159
162
165
168
171
174
177
180
183
186
189
192
195
198
201
204
207
210
213
216
219
222
225
228
231
234
237
240
243
246
249
252
255
258
261
264
267
270
273
276
279
282
285
288
291
294
297
300
303
306
309
312
315
318
321
324
327
330
333
336
339
342
345
348
351
354
357
360
363
366
369
372
375
378
381
384
387
390
393
396
399
402
405
408
411
414
417
420
423
426
429
432
435
438
441
444
447
450
453
456
459
462
465
468
471
474
477
480
483
486
489
492
495
498
501
504
507
510
513
516
519
522
525
528
531
534
537
540
543
546
549
552
555
558
561
564
567
570
573
576
579
582
585
588
591
594
597

@ -0,0 +1,18 @@
void reverse(int n) {
int next;
if (n <= 1) {
next=getint();
putint(next);
}
else {
next=getint();
reverse(n-1);
putint(next);
}
}
int main() {
int i=200;
reverse(i);
return 0;
}

@ -0,0 +1,2 @@
4010
++++++++[->++++++++<]>+++++++++.<+++++[->-----<]>---------.<++++++++[->++++++++<]>++++++.<++++++++[->--------<]>-------------.<+++++++[->+++++++<]>++.<+++++[->+++++<]>+++++++++.+++++.-----.--------.----.<++++[->++++<]>.<++++[->----<]>--------.<++++++++[->--------<]>-.<++++++[->++++++<]>++++.<+++++[->+++++<]>.<++++[->++++<]>+.+++.<+++[->---<]>----.+.<++++++++[->--------<]>---------.<++++++++[->++++++++<]>++++++.<+++[->+++<]>+++.---.--.<++++++++[->--------<]>-------------.<+++++++++[->+++++++++<]>+++.<+++[->---<]>---.---.<++++++++[->--------<]>-----.<++++++[->++++++<]>+.<+++++[->+++++<]>+++.<++++[->++++<]>++.+.<+++++++++[->---------<]>---.<++++++[->++++++<]>++++++.<++++++[->++++++<]>+++++++.-------.-----.++++++.+++.<+++++++++[->---------<]>-.<++++++[->++++++<]>++++.<+++++[->+++++<]>++++++++.--.+.<++++++++[->--------<]>--------.<+++++++[->+++++++<]>++.<++++[->++++<]>.+++++.+++++++..---.<++++++++[->--------<]>.<+++[->---<]>---.<++++++++[->++++++++<]>+.<+++[->+++<]>++++.<+++[->---<]>-.<++++++++[->--------<]>----.<++++++[->++++++<]>+++++.<+++++[->-----<]>---------.<++++++++[->++++++++<]>++++++.<++++++++[->--------<]>-------------.<++++++++[->++++++++<]>++++++++++++++.+.+++++.<+++++++++[->---------<]>---.<++++++++[->++++++++<]>+++++++++.+++++.++++++.<+++[->---<]>------.<+++[->+++<]>++++.<+++[->---<]>----.<+++[->+++<]>+++++.+.<+++[->---<]>------.-.<++++++++[->--------<]>----.<++++++++[->++++++++<]>+++++++++.+++++.<++++++++[->--------<]>--------------.<++++++++[->++++++++<]>+++++++++++++++.+++.<+++[->---<]>-----.+++++.+++++.<+++[->---<]>----.<++++[->++++<]>+.+++++++.<+++++++++[->---------<]>--------.<++++++++[->++++++++<]>++++++++.<+++[->+++<]>++++.--------.<+++[->---<]>---.<+++[->+++<]>++++.+++++.<++++++++[->--------<]>-----.<+++[->---<]>-----.<++++++[->++++++<]>+++++.<+++++[->+++++<]>++++.<++++++++[->--------<]>------.<+++++++++[->+++++++++<]>+++.<+++[->---<]>---.---.<+++[->+++<]>++++.<+++[->---<]>----.<++++++++[->--------<]>-----.<+++++++++[->+++++++++<]>++++++.<++++[->----<]>--.<+++[->+++<]>++++.<+++[->---<]>----.<++++++++[->--------<]>-----.<++++++++[->++++++++<]>+.<+++[->+++<]>++++.<++++++++[->--------<]>--------------.<++++++++[->++++++++<]>+.<+++[->+++<]>++.---.----.+++++++++.<++++++++[->--------<]>--.<+++[->---<]>---.<++++++++[->++++++++<]>+.<++++++++[->--------<]>-.<+++++++++[->+++++++++<]>+++.<+++[->---<]>--.++++.--------.<++++++++[->--------<]>-----.<+++++++++[->+++++++++<]>+++.--.<++++[->----<]>-.<++++[->++++<]>+++++.<++++[->----<]>-.+++++++..-------.<+++[->+++<]>++++.<++++++++[->--------<]>------.<+++[->---<]>---.<++++++++[->++++++++<]>+.<+++[->+++<]>++++.<++++++++[->--------<]>--------------.<++++++++[->++++++++<]>+++++++++++++++.+++++.<+++[->---<]>---.---.<+++[->+++<]>++++.+++++.--------.+++.------.--------.+.<+++[->+++<]>++++.<+++++++++[->---------<]>-.<++++++++[->++++++++<]>+++++++++++++++.+++.<+++++++++[->---------<]>-.<++++++++[->++++++++<]>+.<++++++++[->--------<]>-.<+++++++++[->+++++++++<]>++.++.-----.<+++[->---<]>--.<+++[->+++<]>++++.<+++[->---<]>-.---.<+++[->+++<]>++++.---.<++++++++[->--------<]>---------------.<++++++++[->++++++++<]>+.<+++[->+++<]>+++.++.-.-------.<++++++++[->--------<]>-------.<+++++++++[->+++++++++<]>++++++++.<+++[->---<]>-.++++++.<++++++++[->--------<]>---------.<+++[->---<]>---.<++++++++[->++++++++<]>++++++++++++++++.----.-------.----.<++++[->++++<]>++.<+++[->---<]>-----.<++++++++[->--------<]>-----.<++++++++[->++++++++<]>+++.<+++[->+++<]>+++.--.--------.<++++++++[->--------<]>-----.<+++++++++[->+++++++++<]>+++.-----.<++++++++[->--------<]>---------------.<++++++++[->++++++++<]>+++++++++++++.--------..<+++[->+++<]>++++++.<+++++++++[->---------<]>---.<++++++++[->++++++++<]>+++++++++++++.--------.<++++++++[->--------<]>----.-.<+++++++[->+++++++<]>+++.<++++[->++++<]>++++.-------.<++++[->++++<]>+++.<++++++++[->--------<]>-------------.<++++++++[->++++++++<]>++++++++++++.<+++++++++[->---------<]>--.<++++++++[->++++++++<]>+.<+++[->+++<]>++..<+++++++[->-------<]>-------------.<+++++[->-----<]>--------.---.<

@ -0,0 +1,73 @@
/*
a brainfuck interpreter
reference: https://gist.github.com/maxcountryman/1699708
*/
// tape, input buffer, and read/write pointer
const int TAPE_LEN = 65536, BUFFER_LEN = 32768;
int tape[TAPE_LEN], program[BUFFER_LEN], ptr = 0;
// read the input program
void read_program() {
int i = 0, len = getint();
while (i < len) {
program[i] = getch();
i = i + 1;
}
program[i] = 0;
}
// interpret the input program
void interpret(int input[]) {
int cur_char, loop, i = 0;
while (input[i]) {
cur_char = input[i];
if (cur_char == 62) {
// '>'
ptr = ptr + 1;
}
else if (cur_char == 60) {
// '<'
ptr = ptr - 1;
}
else if (cur_char == 43) {
// '+'
tape[ptr] = tape[ptr] + 1;
}
else if (cur_char == 45) {
// '-'
tape[ptr] = tape[ptr] - 1;
}
else if (cur_char == 46) {
// '.'
putch(tape[ptr]);
}
else if (cur_char == 44) {
// ','
tape[ptr] = getch();
}
else if (cur_char == 93 && tape[ptr]) {
// ']'
loop = 1;
while (loop > 0) {
i = i - 1;
cur_char = input[i];
if (cur_char == 91) {
// '['
loop = loop - 1;
}
else if (cur_char == 93) {
// ']'
loop = loop + 1;
}
}
}
i = i + 1;
}
}
int main() {
read_program();
interpret(program);
return 0;
}

@ -0,0 +1,6 @@
5
1+2* 3/4- 2 *411 ;
0 -1+10*1329000/ 22219 +99 ;
1199+ 98888/2227 %112-23;
* 2;
;

@ -0,0 +1,145 @@
const int TOKEN_NUM = 0, TOKEN_OTHER = 1;
int last_char = 32, num, other;
int cur_token;
int next_char() {
last_char = getch();
return last_char;
}
int is_space(int c) {
if (c == 32 || c == 10) {
return 1;
}
else {
return 0;
}
}
int is_num(int c) {
if (c >= 48 && c <= 57) {
return 1;
}
else {
return 0;
}
}
int next_token() {
while (is_space(last_char)) next_char();
if (is_num(last_char)) {
num = last_char - 48;
while (is_num(next_char())) {
num = num * 10 + last_char - 48;
}
cur_token = TOKEN_NUM;
}
else {
other = last_char;
next_char();
cur_token = TOKEN_OTHER;
}
return cur_token;
}
int panic() {
putch(112);
putch(97);
putch(110);
putch(105);
putch(99);
putch(33);
putch(10);
return -1;
}
int get_op_prec(int op) {
// +, -
if (op == 43 || op == 45) return 10;
// *, /, %
if (op == 42 || op == 47 || op == 37) return 20;
// other
return 0;
}
void stack_push(int s[], int v) {
s[0] = s[0] + 1;
s[s[0]] = v;
}
int stack_pop(int s[]) {
int last = s[s[0]];
s[0] = s[0] - 1;
return last;
}
int stack_peek(int s[]) {
return s[s[0]];
}
int stack_size(int s[]) {
return s[0];
}
int eval_op(int op, int lhs, int rhs) {
// +
if (op == 43) return lhs + rhs;
// -
if (op == 45) return lhs - rhs;
// *
if (op == 42) return lhs * rhs;
// /
if (op == 47) return lhs / rhs;
// %
if (op == 37) return lhs % rhs;
// other
return 0;
}
int eval() {
int oprs[256] = {}, ops[256] = {};
// get the first value
if (cur_token != TOKEN_NUM) return panic();
stack_push(oprs, num);
next_token();
// evaluate
while (cur_token == TOKEN_OTHER) {
// get operator
int op = other;
if (!get_op_prec(op)) break;
next_token();
// handle operator
while (stack_size(ops) && get_op_prec(stack_peek(ops)) >= get_op_prec(op)) {
// evaluate the current operation
int cur_op = stack_pop(ops);
int rhs = stack_pop(oprs), lhs = stack_pop(oprs);
stack_push(oprs, eval_op(cur_op, lhs, rhs));
}
stack_push(ops, op);
// get next expression
if (cur_token != TOKEN_NUM) return panic();
stack_push(oprs, num);
next_token();
}
// eat ';'
next_token();
// clear the operator stack
while (stack_size(ops)) {
int cur_op = stack_pop(ops);
int rhs = stack_pop(oprs), lhs = stack_pop(oprs);
stack_push(oprs, eval_op(cur_op, lhs, rhs));
}
return stack_peek(oprs);
}
int main() {
int count = getint();
getch();
next_token();
while (count) {
putint(eval());
putch(10);
count = count - 1;
}
return 0;
}

@ -0,0 +1,10 @@
6 9
1 2 1
2 3 9
1 3 12
2 4 3
4 3 4
3 5 5
4 5 13
5 6 4
4 6 15

@ -0,0 +1,82 @@
const int INF = 65535;
int e[16][16];
int book[16];
int dis[16];
int n, m;
int v1, v2, w;
void Dijkstra()
{
int i, j;
i = 1;
while (i <= n) {
dis[i] = e[1][i];
book[i] = 0;
i = i + 1;
}
book[1] = 1;
i = 1;
while (i <= n - 1) {
int min_num = INF;
int min_index = 0;
int k = 1;
while (k <= n) {
if (min_num > dis[k] && book[k] == 0) {
min_num = dis[k];
min_index = k;
}
k = k + 1;
}
book[min_index] = 1;
int j = 1;
while (j <= n) {
if (e[min_index][j] < INF) {
if (dis[j] > dis[min_index] + e[min_index][j]) {
dis[j] = dis[min_index] + e[min_index][j];
}
}
j = j + 1;
}
i = i + 1;
}
}
int main()
{
int i;
n = getint();
m = getint();
i = 1;
while (i <= n) {
int j = 1;
while (j <= n) {
if (i == j)
e[i][j] = 0;
else
e[i][j] = INF;
j = j + 1;
}
i = i + 1;
}
i = 1;
while (i <= m) {
int u = getint(), v = getint();
e[u][v] = getint();
i = i + 1;
}
Dijkstra();
i = 1;
while (i <= n) {
putint(dis[i]);
putch(32);
i = i + 1;
}
putch(10);
return 0;
}

@ -0,0 +1,37 @@
6
233 95 179 178 105
115 190 92 216 21
48 252 184 148 36
252 20 92 99 18
61 245 40 190 16
61 197 150 246 225
27 99 197 227 206
130 134 172 149 52
147 246 171 52 84
174 42 90 23 42
130 207 209 104 168
139 248 84 142 225
127 242 45 62 7
102 191 119 168 190
14 249 239 188 118
159 29 212 96 189
159 220 97 71 180
202 131 217 165 138
94 98 86 68 140
132 92 247 99 110
228 10 119 127 21
247 8 230 81 251
216 213 24 114 68
83 188 240 196 231
90 206 224 49 28
158 252 95 171 239
90 66 22 221 10
177 32 38 24 93
227 55 4 59 211
80 92 38 238 42

@ -0,0 +1,50 @@
int relu_reg(int a)
{
if (a > 0x7F) return 0x7F;
if (a < 0) return 0;
return a;
}
int model(int a[][5])
{
if (+ relu_reg( + a[0][0] * 85 + a[0][1] * 23 + a[0][2] * -82 + a[0][3] * -103 + a[0][4] * -123 + a[1][0] * 64 + a[1][1] * -120 + a[1][2] * 50 + a[1][3] * -59 + a[1][4] * 47 + a[2][0] * -111 + a[2][1] * -67 + a[2][2] * -106 + a[2][3] * -75 + a[2][4] * -102 + a[3][0] * 34 + a[3][1] * -39 + a[3][2] * 65 + a[3][3] * 47 + a[3][4] * 113 + a[4][0] * 110 + a[4][1] * 47 + a[4][2] * -4 + a[4][3] * 80 + a[4][4] * 46) * 39
+ relu_reg( + a[0][0] * -106 + a[0][1] * 126 + a[0][2] * -18 + a[0][3] * -31 + a[0][4] * -8 + a[1][0] * 47 + a[1][1] * -4 + a[1][2] * 67 + a[1][3] * -94 + a[1][4] * -121 + a[2][0] * 7 + a[2][1] * -21 + a[2][2] * -60 + a[2][3] * -43 + a[2][4] * 105 + a[3][0] * -42 + a[3][1] * 87 + a[3][2] * 29 + a[3][3] * -106 + a[3][4] * -31 + a[4][0] * -110 + a[4][1] * -100 + a[4][2] * -22 + a[4][3] * -75 + a[4][4] * -125) * 77
+ relu_reg( + a[0][0] * 26 + a[0][1] * 76 + a[0][2] * -70 + a[0][3] * 29 + a[0][4] * -95 + a[1][0] * 96 + a[1][1] * 52 + a[1][2] * -68 + a[1][3] * -5 + a[1][4] * 34 + a[2][0] * -34 + a[2][1] * 102 + a[2][2] * 6 + a[2][3] * -38 + a[2][4] * 27 + a[3][0] * 110 + a[3][1] * 116 + a[3][2] * 39 + a[3][3] * -63 + a[3][4] * -99 + a[4][0] * 65 + a[4][1] * 120 + a[4][2] * -39 + a[4][3] * -6 + a[4][4] * 94) * 127
+ relu_reg( + a[0][0] * -23 + a[0][1] * -63 + a[0][2] * 49 + a[0][3] * 50 + a[0][4] * 72 + a[1][0] * 85 + a[1][1] * -30 + a[1][2] * 12 + a[1][3] * 125 + a[1][4] * -117 + a[2][0] * -65 + a[2][1] * -67 + a[2][2] * 125 + a[2][3] * 110 + a[2][4] * -31 + a[3][0] * -123 + a[3][1] * 83 + a[3][2] * 122 + a[3][3] * 11 + a[3][4] * -23 + a[4][0] * -47 + a[4][1] * -32 + a[4][2] * -117 + a[4][3] * 95 + a[4][4] * 118) * -106
+ relu_reg( + a[0][0] * 8 + a[0][1] * 82 + a[0][2] * -104 + a[0][3] * 101 + a[0][4] * -116 + a[1][0] * -63 + a[1][1] * -16 + a[1][2] * -70 + a[1][3] * 125 + a[1][4] * 75 + a[2][0] * 66 + a[2][1] * -96 + a[2][2] * -101 + a[2][3] * -114 + a[2][4] * 59 + a[3][0] * 12 + a[3][1] * 5 + a[3][2] * -95 + a[3][3] * 116 + a[3][4] * -93 + a[4][0] * 15 + a[4][1] * 79 + a[4][2] * 3 + a[4][3] * 49 + a[4][4] * -124) * -3
+ relu_reg( + a[0][0] * 81 + a[0][1] * 68 + a[0][2] * -102 + a[0][3] * -74 + a[0][4] * 121 + a[1][0] * -15 + a[1][1] * 55 + a[1][2] * 101 + a[1][3] * -13 + a[1][4] * -62 + a[2][0] * 64 + a[2][1] * 114 + a[2][2] * 38 + a[2][3] * -21 + a[2][4] * 112 + a[3][0] * 114 + a[3][1] * 112 + a[3][2] * -10 + a[3][3] * -16 + a[3][4] * -50 + a[4][0] * -112 + a[4][1] * -116 + a[4][2] * -54 + a[4][3] * 82 + a[4][4] * -72) * 32
+ relu_reg( + a[0][0] * 15 + a[0][1] * -77 + a[0][2] * 66 + a[0][3] * -90 + a[0][4] * -6 + a[1][0] * -30 + a[1][1] * -8 + a[1][2] * 81 + a[1][3] * 2 + a[1][4] * -110 + a[2][0] * -95 + a[2][1] * 59 + a[2][2] * 52 + a[2][3] * 15 + a[2][4] * 55 + a[3][0] * -33 + a[3][1] * 14 + a[3][2] * 58 + a[3][3] * 67 + a[3][4] * 86 + a[4][0] * -79 + a[4][1] * 48 + a[4][2] * -13 + a[4][3] * -15 + a[4][4] * 66) * -95
+ relu_reg( + a[0][0] * 33 + a[0][1] * 82 + a[0][2] * 67 + a[0][3] * 30 + a[0][4] * -2 + a[1][0] * 65 + a[1][1] * 120 + a[1][2] * -13 + a[1][3] * 18 + a[1][4] * 5 + a[2][0] * 104 + a[2][1] * -119 + a[2][2] * -7 + a[2][3] * 71 + a[2][4] * 107 + a[3][0] * 24 + a[3][1] * 82 + a[3][2] * -96 + a[3][3] * -104 + a[3][4] * -121 + a[4][0] * 65 + a[4][1] * 97 + a[4][2] * 83 + a[4][3] * 46 + a[4][4] * -84) * -50
+ relu_reg( + a[0][0] * -29 + a[0][1] * 7 + a[0][2] * -70 + a[0][3] * 38 + a[0][4] * -90 + a[1][0] * -15 + a[1][1] * -32 + a[1][2] * 37 + a[1][3] * 36 + a[1][4] * -62 + a[2][0] * -125 + a[2][1] * -46 + a[2][2] * -70 + a[2][3] * 37 + a[2][4] * -73 + a[3][0] * -34 + a[3][1] * -87 + a[3][2] * -75 + a[3][3] * 71 + a[3][4] * -77 + a[4][0] * 53 + a[4][1] * 37 + a[4][2] * -103 + a[4][3] * -13 + a[4][4] * -114) * -23
+ relu_reg( + a[0][0] * 67 + a[0][1] * 42 + a[0][2] * 41 + a[0][3] * -123 + a[0][4] * -92 + a[1][0] * 10 + a[1][1] * -77 + a[1][2] * 75 + a[1][3] * 96 + a[1][4] * -51 + a[2][0] * 109 + a[2][1] * -74 + a[2][2] * -7 + a[2][3] * -122 + a[2][4] * 67 + a[3][0] * 47 + a[3][1] * 22 + a[3][2] * -68 + a[3][3] * 38 + a[3][4] * 29 + a[4][0] * 115 + a[4][1] * -121 + a[4][2] * 36 + a[4][3] * -49 + a[4][4] * 85) * 46
> 0)
return 1;
return 0;
}
int main()
{
int N = getint();
int a[5][5];
while (N > 0) {
int i = 0;
while (i < 5) {
int j = 0;
while (j < 5) {
a[i][j] = getint();
j = j + 1;
}
i = i + 1;
}
if (model(a)) {
// cat
putch(99); putch(97); putch(116); putch(10);
} else {
// dog
putch(100); putch(111); putch(103); putch(10);
}
N = N - 1;
}
return 0;
}

@ -0,0 +1,27 @@
void move(int x, int y)
{
putint(x); putch(32); putint(y); putch(44); putch(32);
}
void hanoi(int n, int one, int two, int three)
{
if (n == 1)
move(one, three);
else {
hanoi(n - 1, one, three, two);
move(one, three);
hanoi(n - 1, two, one, three);
}
}
int main()
{
int n = getint();
while (n > 0) {
hanoi(getint(), 1, 2, 3);
putch(10);
n = n - 1;
}
return 0;
}

@ -0,0 +1,14 @@
5
4006571
9900
1504379
758219
99336677

@ -0,0 +1,52 @@
const int ascii_0 = 48;
int my_getint()
{
int sum = 0, c;
while (1) {
c = getch() - ascii_0;
if (c < 0 || c > 9) {
continue;
} else {
break;
}
}
sum = c;
while (1) {
c = getch() - ascii_0;
if (c >= 0 && c <= 9) {
sum = sum * 10 + c;
} else {
break;
}
}
return sum;
}
void my_putint(int a)
{
int b[16], i = 0;
while (a > 0) {
b[i] = a % 10 + ascii_0;
a = a / 10;
i = i + 1;
}
while (i > 0) {
i = i - 1;
putch(b[i]);
}
}
int main()
{
int n = my_getint();
while (n > 0) {
int m = my_getint();
my_putint(m); putch(10);
n = n - 1;
}
return 0;
}

@ -0,0 +1,2 @@
abcabdbca
aababcabdabdababcabdbcadceadbcababcdcbaabsbda

@ -0,0 +1,62 @@
void get_next(int str[], int next[])
{
next[0] = -1;
int i = 0, j = -1;
while (str[i]) {
if (j == -1 || str[i] == str[j]) {
j = j + 1;
i = i + 1;
next[i] = j;
}
else
j = next[j];
}
}
int KMP(int dst[], int src[])
{
int next[4096];
get_next(dst, next);
int i = 0, j = 0;
while (src[j]) {
if (dst[i] == src[j]) {
i = i + 1;
j = j + 1;
if (!dst[i]) {
return j;
}
} else {
i = next[i];
if (i == -1) {
i = i + 1;
j = j + 1;
}
}
}
return -1;
}
int read_str(int buf[])
{
int i = 0;
while (1) {
buf[i] = getch();
if (buf[i] == 10)
break;
i = i + 1;
}
buf[i] = 0;
return i;
}
int main()
{
int dst[4096], src[4096];
read_str(dst);
read_str(src);
putint(KMP(dst, src));
putch(10);
return 0;
}

@ -0,0 +1,12 @@
7 11
1 6 22
1 3 10
1 4 56
3 7 15
3 5 11
5 7 45
4 5 100
6 3 34
2 3 9
6 7 68
6 2 6

@ -0,0 +1,96 @@
/*
* Max flow EK with DFS.
*/
const int INF = 0x70000000;
int size[10];
int to[10][10];
int cap[10][10];
int rev[10][10];
int used[10];
void my_memset(int arr[], int val, int n)
{
int i = 0;
while (i < n) {
arr[i] = val;
i = i + 1;
}
}
void add_node(int u, int v, int c)
{
to[u][size[u]] = v;
cap[u][size[u]] = c;
rev[u][size[u]] = size[v];
to[v][size[v]] = u;
cap[v][size[v]] = 0;
rev[v][size[v]] = size[u];
size[u] = size[u] + 1;
size[v] = size[v] + 1;
}
int dfs(int s, int t, int f)
{
if (s == t)
return f;
used[s] = 1;
int i = 0;
while (i < size[s]) {
if (used[to[s][i]]) { i = i + 1; continue; }
if (cap[s][i] <= 0) { i = i + 1; continue; }
int min_f;
if (f < cap[s][i])
min_f = f;
else
min_f = cap[s][i];
int d = dfs(to[s][i], t, min_f);
if (d > 0) {
cap[s][i] = cap[s][i] - d;
cap[to[s][i]][rev[s][i]] = cap[to[s][i]][rev[s][i]] + d;
return d;
}
i = i + 1;
}
return 0;
}
int max_flow(int s, int t)
{
int flow = 0;
while (1) {
my_memset(used, 0, 10);
int f = dfs(s, t, INF);
if (f == 0)
return flow;
flow = flow + f;
}
}
int main()
{
int V, E;
V = getint();
E = getint();
my_memset(size, 0, 10);
while (E > 0) {
int u, v;
u = getint();
v = getint();
int c = getint();
add_node(u, v, c);
E = E - 1;
}
putint(max_flow(1, V));
putch(10);
return 0;
}

@ -0,0 +1,49 @@
int ans[50], sum = 0, n;
int row[50], line1[50], line2[100];
void printans()
{
sum = sum + 1;
int i = 1;
while (i <= n) {
putint(ans[i]);
if (i == n) {
putch(10);
return;
} else
putch(32);
i = i + 1;
}
}
void f(int step)
{
int i = 1;
while (i <= n) {
if (row[i] != 1 && line1[step + i] == 0 && !line2[n + step - i]) {
ans[step] = i;
if (step == n)
printans();
row[i] = 1;
line1[step + i] = 1;
line2[n + step - i] = 1;
f(step + 1);
row[i] = 0;
line1[step + i] = 0;
line2[n + step - i] = 0;
}
i = i + 1;
}
}
int main()
{
int N = getint();
while (N > 0) {
n = getint();
f(1);
N = N - 1;
}
return sum;
}

@ -0,0 +1,58 @@
int MAX(int a, int b)
{
if (a == b)
return a;
else if (a > b)
return a;
else
return b;
}
int max_sum_nonadjacent(int arr[], int n)
{
int temp[16] = {};
temp[0] = arr[0];
temp[1] = MAX(arr[0], arr[1]);
int i = 2;
while (i < n) {
temp[i] = MAX(temp[i - 2] + arr[i], temp[i - 1]);
i = i + 1;
}
return temp[n - 1];
}
int longest_common_subseq(int arr1[], int len1,
int arr2[], int len2)
{
int p[16][16] = {};
int i, j;
i = 1;
while (i <= len1) {
j = 1;
while (j <= len2) {
if (arr1[i - 1] == arr2[j - 1]) {
p[i][j] = p[i - 1][j - 1] + 1;
} else {
p[i][j] = MAX(p[i - 1][j], p[i][j - 1]);
}
j = j + 1;
}
i = i + 1;
}
return p[len1][len2];
}
int main()
{
int A[15] = {8, 7, 4, 1, 2, 7, 0, 1, 9, 3, 4, 8, 3, 7, 0};
int B[13] = {3, 9, 7, 1, 4, 2, 4, 3, 6, 8, 0, 1, 5};
int An, Bn;
putint(max_sum_nonadjacent(A, 15));
putch(10);
putint(longest_common_subseq(A, 15, B, 13));
putch(10);
return 0;
}

@ -0,0 +1,29 @@
int a = -1, b = 1;
int inc_a()
{
int b = a;
b = b + 1;
a = b;
return a;
}
int main()
{
int k = 5;
while (k >= 0) {
if (inc_a() && inc_a() && inc_a()) {
putint(a); putch(32); putint(b); putch(10);
}
if (inc_a() < 14 || inc_a() && inc_a() - inc_a() + 1) {
putint(a); putch(10);
b = b * 2;
} else {
inc_a();
}
k = k - 1;
}
putint(a); putch(32); putint(b); putch(10);
return a;
}

File diff suppressed because one or more lines are too long

@ -0,0 +1,201 @@
int __HELLO [
100
]
= {
87, 101, 108, 99,
111, 109, 101,
32, 116, 111, 32,
116, 104,
101, 32, 74,
97,
112, 97,
114, 105, 32, 80, 97,
114, 107, 33, 10 }; /* Names of
kemono
friends */ int N4__mE___[6][50] = { { 83, 97, 97, 98,
97,
114,
117 }, { 75, 97, 98,
97, 110
}, {
72,
97,
115, 104, 105,
98, 105, 114, 111,
107,
111,
117
}, { 65, 114,
97,
105,
103,
117,
109,
97 },
{ 72, 117,
110, 98, 111, 114,
117,
116, 111, 32, 80,
101, 110,
103, 105, 110
},
{ 84, 97, 105, 114, 105, 107, 117, 32, 79,
111, 107,
97,
109,
105 } };
int
saY_HeI10_To[40] = { 32,
115, 97, 121,
115,
32,
104,
101, 108, 108, 111,
32,
116, 111,
32 }; int
RET[5]
=
{10}; int putstr(
int str[ ] ) {
int
iNd__1X ; iNd__1X = 0 ; while ( str
[ iNd__1X
] ) {
putch (
str[ iNd__1X
]
) ; iNd__1X
=
iNd__1X
+ 1
; } return iNd__1X
; } int main( /* no param */ ) {
putstr(
__HELLO ) ; int i =
0 ; /* say
hello to
kemono friends
~ */ while (
1 ) {
int _
= i
/ 6
; int __
=
i % 6
;
if
(
_
!=
__ )
{ putstr(
N4__mE___
[ _
] )
; putstr(
saY_HeI10_To ) ;
putstr(
N4__mE___ [
__ ] )
;
putstr(
RET
) ;
}
/*
do
linear
modulo
to find the next pair of friends */ i = ( i
*
17
+ 23
)
%
32
;
if ( i
==
0 ) { break ; }
} return 0; }

@ -0,0 +1,3 @@
1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18 19 20
23 233 2333 23333 233333 0 0

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

Loading…
Cancel
Save