Anne

Anne.github.io


  • Home

  • About

  • Tags

  • Categories

  • Archives

Rakiki--Machine Learning as an Analytics Service System

Posted on 2018-10-09 | In paper

Machine Learning as an Analytics Service System

Key words: training, inference, latency, accuracy

1. Introduction

Approaches to integrating the machine learning techniques into database applications:

  • preprocess the data off-line and add the predictions results into a new columnyin
  • carry out the prediction on-line as user-defined functions (UDFs) in the SQL query
  • better solution is to call the corresponding cloud machine learning service, e.g. APIs, disadvantage:
    • the accuracy could be low since the models are trained by Amazon and Google with general data
    • only a limited number of machine learning models are supported
Read more »

Interview--C Basic Problems

Posted on 2018-09-23 | In Interview

C Language Classic Problems

最大公约数 最小公倍数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>
int main(){
int num1, num2;
scanf("%d%d", &num1, &num2);
int n = num1, m = num2, temp = 0;
// make m < n
if(m > n){
temp = m;
m = n;
n= temp;
}
while(m != 0){
temp = n % m;
n = m;
m = temp;
}
printf("最大公约数:%d\n", n);
printf("最小公倍数:%d", num1 * num2 / n);
}

递归方法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>
int GCD(int m, int n){
if(m % n == 0)
return n;
else return GCD(n, m%n);
}
int main(){
int m,n,temp;
printf("Please input m and n\n");
scanf("%d %d", &m, &n);
if(m < n){ // ensure m > n
temp = m;
m = n;
n = temp;
}
printf("The greatest common divisor of (%d,%d) is %d\n", m, n, GCD(m,n));
return 0;
}

isPrime

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdio.h>
#include <stdbool.h>
bool is_prime(int n){
int divisor;
if(n <= 1)
return false;
for(divisor = 2; divisor * divisor <= n; divisor++)
if(n % divisor == 0)
return false;
return true;
}
int main(void){
int n;
printf("Enter a number:");
scanf("%d", &n);
if(is_prime(n))
printf("isPrime\n");
else
printf("notPrime\n");
return 0;
}
Read more »

Interview--C Language

Posted on 2018-09-23 | In Interview

C Language

汇编语言

汇编语言是直接面向处理器的、面向机器的程序设计语言,属于低级语言

不同的处理器有不同的汇编语言语法和编译器,编译的程序无法在不同的处理器上执行,缺乏可移植性

C语言特点

允许直接访问物理地址,能进行位操作,实现汇编语言的大部分功能,可直接对硬件进行操作,兼有高级和低级语言的特点

目标代码质量高,程序执行率高,只比汇编程序生成的目标代码效率低10%-20%

程序可移植性好,基本上不做修改就能用于各种型号的计算机和各种OS

Read more »

NLP-Summary

Posted on 2018-09-17 | In NLP

Some good resources

to be continued…

Read more »

Jobdu-1458.汉诺塔III

Posted on 2018-09-11 | In Jobdu

Question

题目描述

约 19 世纪末,在欧州的商店中出售一种智力玩具,在一块铜板上有三根杆, 最左边的杆上自上而下、由小到大顺序串着由 64 个圆盘构成的塔。目的是将最 左边杆上的盘全部移到右边的杆上,条件是一次只能移动一个盘,且不允许大盘 放在小盘的上面。现在我们改变游戏的玩法,不允许直接从最左(右)边移到最右 (左)边(每次移动一定是移到中间杆或从中间移出),也不允许大盘放到下盘的上 面。Daisy 已经做过原来的汉诺塔问题和汉诺塔 II,但碰到这个问题时,她想了 很久都不能解决,现在请你帮助她。现在有 N 个圆盘,她至少多少次移动才能 把这些圆盘从最左边移到最右边?

输入
包含多组数据,每次输入一个N值(1<=N=35)。 输出: 对于每组数据,输出移动最小的次数

样例输入

1
2
3
1
3
12

样例输出

1
2
3
2
26
531440
Read more »

Jobdu-1456.胜利大逃往

Posted on 2018-09-06 | In Jobdu

Question

题目描述:

Ignatius被魔王抓走了,有一天魔王出差去了,这可是Ignatius逃亡的好机会.魔王住在一个城堡里,城堡是一个ABC的立方体,可以被表示成A个B*C的矩阵,刚开始Ignatius被关在(0,0,0)的位置,离开城堡的门在(A-1,B-1,C-1)的位置,现在知道魔王将在T分钟后回到城堡,Ignatius每分钟能从一个坐标走到相邻的六个坐标中的其中一个.现在给你城堡的地图,请你计算出Ignatius能否在魔王回来前离开城堡(只要走到出口就算离开城堡,如果走到出口的时候魔王刚好回来也算逃亡成功),如果可以请输出需要多少分钟才能离开,如果不能则输出-1.

输入:

输入数据的第一行是一个正整数K,表明测试数据的数量.每组测试数据的第一行是四个正整数A,B,C和T(1<=A,B,C<=50,1<=T<=1000),它们分别代表城堡的大小和魔王回来的时间.然后是A块输入数据(先是第0块,然后是第1块,第2块……),每块输入数据有B行,每行有C个正整数,代表迷宫的布局,其中0代表路,1代表墙。

输出:

对于每组测试数据,如果Ignatius能够在魔王回来前离开城堡,那么请输出他最少需要多少分钟,否则输出-1.

样例输入:

1 3 3 4 20 0 1 1 1 0 0 1 1 0 1 1 1 1 1 1 1 1 0 0 1 0 1 1 1 0 0 0 0 0 1 1 0 0 1 1 0

样例输出:

11

Read more »

NLP introduction--NLTK

Posted on 2018-09-04 | In NLP

import nltk

统计词频

1
freq = nltk.FreqDist(tokens)

处理停用词

1
2
from nltk.corpus import stopwords
stopwords.words('english')
Read more »

Jobdu-1455.珍惜生活 感恩现在 多重背包问题

Posted on 2018-09-03 | In Jobdu

Question

题目描述

为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾
区,现在假设你一共有资金 n 元,而市场有m种大米,每种大米都是袋装产品, 其价格不等,并且只能整袋购买。请问:你用有限的资金最多能采购多少公斤粮 食呢?

输入
输入数据首先包含一个正整数C,表示有C组测试用例,每组测试用例的第 一行是两个整数 n 和 m(1<=n<=100, 1<=m<=100),分别表示经费的金额和大米的 种类,然后是 m 行数据,每行包含 3 个数 p , h 和 c(1<=p<=20,1<=h<=200,1<=c<=20),分别表示每袋的价格、每袋的重量以及对应 种类大米的袋数。

输出
对于每组测试数据,请输出能够购买大米的最多重量,你可以假设经费买不 光所有的大米,并且经费你可以不用完。每个实例的输出占一行。

样例输入

1
2
3
4
1
8 2
2 100 4
4 100 2
Read more »

Jobdu-1454.Piggy-Bank 完全背包问题

Posted on 2018-09-03 | In Jobdu

Question

题目描述:

Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irreversibly Bound Money (IBM). The idea behind is simple. Whenever some ACM member has any small money, he takes all the coins and throws them into a piggy-bank. You know that this process is irreversible, the coins cannot be removed without breaking the pig. After a sufficiently long time, there should be enough cash in the piggy-bank to pay everything that needs to be paid. But there is a big problem with piggy-banks. It is not possible to determine how much money is inside. So we might break the pig into pieces only to find out that there is not enough money. Clearly, we want to avoid this unpleasant situation. The only possibility is to weigh the piggy-bank and try to guess how many coins are inside. Assume that we are able to determine the weight of the pig exactly and that we know the weights of all coins of a given currency. Then there is some minimum amount of money in the piggy-bank that we can guarantee. Your task is to find out this worst case and determine the minimum amount of cash inside the piggy-bank. We need your help. No more prematurely broken pigs!

输入:

The input consists of T test cases. The number of them (T) is given on the first line of the input file. Each test case begins with a line containing two integers E and F. They indicate the weight of an empty pig and of the pig filled with coins. Both weights are given in grams. No pig will weigh more than 10 kg, that means 1 <= E <= F <= 10000. On the second line of each test case, there is an integer number N (1 <= N <= 500) that gives the number of various coins used in the given currency. Following this are exactly N lines, each specifying one coin type. These lines contain two integers each, Pand W (1 <= P <= 50000, 1 <= W <=10000). P is the value of the coin in monetary units, W is it’s weight in grams.

输出:

Print exactly one line of output for each test case. The line must contain the sentence “The minimum amount of money in the piggy-bank is X.” where X is the minimum amount of money that can be achieved using coins with the given total weight. If the weight cannot be reached exactly, print a line “This is impossible.”.

样例输入:

1
2
3
4
5
6
7
8
9
10
11
12
3
10 110
2
1 1
30 50
10 110
2
1 1
50 30
1
6 2
10

3 10 110 2 1 1 30 50 10 110 2 1 1 50 30 1 6 2 10 3 20 4

样例输出:

The minimum amount of money in the piggy-bank is 60. The minimum amount of money in the piggy-bank is 100. This is impossible.T代表几组数据,然后每组的第一对是E和F代表存钱罐本身的重量和加上钱以后的重量,然后是n对数据代表,可能的硬币的价值和重量求现在存钱罐最少可以装的钱

Read more »

Jobdu-1123.采药0/1背包问题

Posted on 2018-09-03 | In Jobdu

Question

题目描述:

辰辰是个很有潜能、天资聪颖的孩子,他的梦想是称为世界上最伟大的医师。 为此,他想拜附近最有威望的医师为师。医师为了判断他的资质,给他出了一个难题。 医师把他带到个到处都是草药的山洞里对他说: “孩子,这个山洞里有一些不同的草药,采每一株都需要一些时间,每一株也有它自身的价值。 我会给你一段时间,在这段时间里,你可以采到一些草药。如果你是一个聪明的孩子,你应该可以让采到的草药的总价值最大。” 如果你是辰辰,你能完成这个任务吗?

输入:

输入的第一行有两个整数T(1 <= T <= 1000)和M(1 <= M <= 100),T代表总共能够用来采药的时间,M代表山洞里的草药的数目。 接下来的M行每行包括两个在1到100之间(包括1和100)的的整数,分别表示采摘某株草药的时间和这株草药的价值。

输出:

可能有多组测试数据,对于每组数据, 输出只包括一行,这一行只包含一个整数,表示在规定的时间内,可以采到的草药的最大总价值。

样例输入:

70 3 71 100 69 1 1 2

样例输出:

3

Read more »
1234…14
Anne_ZAJ

Anne_ZAJ

boom pow

134 posts
14 categories
17 tags
0%
© 2019 Anne_ZAJ
Powered by Hexo
|
Theme — NexT.Pisces v5.1.3