进阶6:兔子的速度v1(表示每秒兔子能跑v1米),乌龟的速度v2,以及赛道的长度l,一旦任一秒结束后兔子发现自己领先t米或以上,它们就会停下来休息s秒。
cpp
#include <bits/stdc++.h>
using namespace std;
int main(){
int v1,v2,t,s,l;
cin>>v1>>v2>>t>>s>>l;
int time=0;
int l1=0,l2=0;
while(l1<l&&l2<l){
time++;l1 = l1+v1;l2 = l2+v2;
if(l1>=l||l2>=l)break;
if(l1-l2 >= t){
int tempT= s;
while(tempT-->0){
time+=1;l2 = l2 + v2;
if(l2>=l)break;
}
}
}
if(l2>l1)cout<<'T'<<endl;
if(l2==l1)cout<<'D'<<endl;
if(l2<l1)cout<<'R'<<endl;
cout<<time<<endl;
system("pause");
}
题77:写一个程序来找出将原始图案按照以下列转换方法转换成新图案的最小方式,如果有多种可用的转换方法,请选择序号最小的那个。
#1:转90度:图案按顺时针转90度。
#2:转180度:图案按顺时针转180度。
#3:转270度:图案按顺时针转270度。
#4:反射:图案在水平方向翻转(形成原图案的镜像)。
#5:组合:图案在水平方向翻转,然后按照#1-#3之一转换。
#6:不改变:原图案不改变。
#7:无效转换:无法用以上方法得到新图案。
cpp
void Fun1(vector<vector<char>>& m,vector<vector<char>> matrix,vector<vector<char>> &target){
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
m[j][n-1-i] = matrix[i][j];
}
}
}
bool Fun2(vector<vector<char>> &m,vector<vector<char>> matrix,vector<vector<char>> &target){
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
m[n-1-i][n-1-j] = matrix[i][j];
}
}
}
bool Fun3(vector<vector<char>> &m,vector<vector<char>> matrix,vector<vector<char>> &target){
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
m[n-1-j][n-1-i] = matrix[i][j];
}
}
}
bool Fun4(vector<vector<char>> &m,vector<vector<char>> matrix,vector<vector<char>> &target){
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
m[i][n-1-j] = matrix[i][j];
}
}
}
- 二刷,做得很慢,找原矩阵的转化映射规律。
题80:饲料调配,给出目标饲料和三组整数,表示 大麦:燕麦:小麦 的比例,找出用这三种饲料调配目标饲料的方法。
cpp
#include <bits/stdc++.h>
using namespace std;
int main(){
int TargetX,TargetY,TargetZ;
cin>>TargetX>>TargetY>>TargetZ;
vector<vector<int>> matrix(3,vector<int>(3,0));
for(int i=0;i<3;i++){
for(int j=0;j<3;j++)cin>>matrix[i][j];
}
//------------------------------------------
for(int i=0;i<100;i++){
for(int j=0;j<100;j++){
for(int k=0;k<100;k++){
int numA=i*matrix[0][0]+
j*matrix[1][0]+k*matrix[2][0];
int numB=i*matrix[0][1]+
j*matrix[1][1]+k*matrix[2][1];
int numC=i*matrix[0][2]+
j*matrix[1][2]+k*matrix[2][2];
int xishu;
if(TargetX!=0)xishu=numA/TargetX;
else if(TargetY!=0)xishu=numB/TargetY;
if(xishu*TargetX==numA&&xishu*TargetY==numB&&xishu*TargetZ==numC){
if(i==0&&j==0&&k==0)continue;
cout<<i<<' '<<j<<' '<<k<<' '<<xishu<<endl;
system("pause");return 0;
}
}
}
}
cout<<"NONE";
}
- 越界异常之一为除0,且测试案例可能为0,对测试输入要考虑最小值和最大值并在编写时注意该边界情况。
Neural machine translation has recently shown impressive results (Kalchbrenner and Blunsom, 2013; Sutskever et al., 2014; Bahdanau et al., 2015). However, the translation of rare words is an open problem. The vocabulary of neu ral models is typically limited to 30000--50000 words, but translation is an open-vocabulary problem, and especially for languages with produc tive word formation processes such as aggluti nation and compounding, translation models re quire mechanisms that go below the word level. As an example, consider compounds such as the German Abwasser|behandlungs|anlange `sewage water treatment plant', for which a segmented, variable-length representation is intuitively more appealing than encoding the word as a fixed-length vector.
- 神经机器翻译近来展现出惊人的结果。然而,罕见词的翻译是一个待解决的 问题。神经模型的词汇量普遍限制在三万到五万单词之间,但是翻译是一个无限词汇 问题,特别是能产性构词方式的 语言中创造性的单词规范化处理例如凝集作用黏着 和复合,翻译模型需要深入 单词级别之下的机制。比如,考虑像德语中 Abwasser|behandlungs|anlange `sewage water treatment plant' 这样的分段的复合词,采用分段的 可变长度表示显然 是比将单词编码为固定长度向量的更本能的吸引更为合理。
open problem待解决的难题open-vocabulary problem无限词汇问题productive word formation processes产性构词方式过程go below深入...以下agglutination黏着intuitively more appealing显然更为合理/在直觉上更具吸引力
For word-level NMT models, the translation of out-of-vocabulary words has been addressed through a back-off to a dictionary look-up (Jean et al., 2015; Luong et al., 2015b). We note that such techniques make assumptions that often do not hold true in practice. For instance, there is not al ways a 1-to-1 correspondence between source and target words because of variance in the degree of morphological synthesis between languages, like in our introductory compounding example. Also, word-level models are unable to translate or gen erate unseen words. Copying unknown words into the target text, as done by (Jean et al., 2015; Luong et al., 2015b), is a reasonable strategy for names, but morphological changes and transliteration is often required, especially if alphabets differ.
- 对于单词级别的词级 NMT模型,词汇表之外的单词的翻译已经通过后退至词典的查找而解决。我们发现这样的技术做出了实际不对的假设做出的假设往往在实践中不成立 。比如,在源和目标单词之间不总是有一对一的关联对应 ,因为语言之间的语法的合成程度形态综合程度 差异,就像我们介绍的复合案例。同样,单词级别模型不能翻译或生成没见过的单词。将未见过的单词复制成目标文本,正如由简做得,对于专有名词 是一个合理的策略,但是通常需要进行 语法的形态 变化和通常必要的音译,特别是如果使用不同 字母表不同。
- morphological 形态上的/语法的,synthesis 合成,introductory 介绍性的,transliteration 音译,differ 不同/相异
- out-of-vocabulary words 集外词
morphological synthesis形态综合- name 专有名词
- morphological changes and transliteration is often required 其中is often required是修饰morphological changes and transliteration这两者为一个整体的。