zoukankan      html  css  js  c++  java
  • woj1013 Barcelet 字符串 woj1014 Doraemon's Flashlight 几何


    title: woj1013 Barcelet 字符串
    date: 2020-03-18 18:00:00
    categories: acm
    tags: [acm,字符串,woj]

    字符串,字典序。

    1 描述

    Some beads are embedded in a bracelet, and each beads is carved with a lower case letter, as the follow figure shows:
    woj1013.PNG
    If we read the letters in counter clockwise with different initial position, we may get different strings. The above example, we can read 6 strings:
    acabdb
    cabdba
    abdbac
    bdbaca
    dbacab
    bacabd
    Sort these strings in lexical order, we obtain:
    abdbac
    acabdb
    bacabd
    bdbaca
    cabdba
    dbacab
    What we need is the first string: abdbac.

    2 输入输出

    输入格式
    A string of lower case letters representing the letters carved on the bracelet (in counter clockwise order).
    The length of the string is no more than 100.

    输出格式
    Output the first string of all the possible strings after sorting them in lexical order.

    3 样例

    样例输入
    acabdb
    kkisverystupid
    样例输出
    abdbac
    dkkisverystupi

    4 分析

    //题意,输入字符串,看成环,从任一点开始一周构成“子串”,输出字典序最小的串
    //比如 输入 1236 子串有1236 2361 3612 6123输出1236

    因为数据量很小,就算出来所有的排列,然后sort就行

    5 code

    #include<iostream>
    #include<algorithm>
    #include<cstring> 
    #include<vector>
    using namespace std;
    
    bool cmp1(string a,string b){
        return a<b;
    }
    bool cmp(char*a,char*b){
        return strcmp(a,b);
    }
    
    char origin[105];
    char mapp[105][105];
    
    string ori;
    vector<string>ans;
    string tmp;
    int main(){
    
    while(cin>>ori){
        int len=ori.length();  //string.length() .size()
            for(int i=0;i<len;i++){
                tmp=ori;
                for(int j=0;j<len;j++){
                    tmp[j]=ori[(i+j)%len];
                }
                //mapp[i][len]='';  //essential C可以这样,C++不行。 Array must be initialized with a brace enclosed initializer
                //mapp[i][len]=;
                ans.push_back(tmp);
            }
            sort(ans.begin(),ans.end(),cmp1);
            cout<<ans[0]<<endl;
            ans.clear();  //别忘了
    }
    
    /* 
        while(scanf("%s",origin)!=EOF){
            int len=strlen(origin);  //string.length() .size()
            for(int i=0;i<len;i++){
                for(int j=0;j<len;j++){
                    mapp[i][j]=origin[(i+j)%len];
                }
                //mapp[i][len]='';  //essential C可以这样,C++不行。 Array must be initialized with a brace enclosed initializer
                //mapp[i][len]=;  没找到解决办法 T_T 应该是初始化的问题
            }
            sort(mapp,mapp+len,cmp);
            cout<<mapp[0]<<endl;
    
        }
        */
        return 0;
    }
    

    title: woj1014 Doraemon's Flashlight 几何
    date: 2020-03-18 19:00:00
    categories: acm
    tags: [acm,几何,数学,woj]

    几何题。矩阵*几何体,行列式即为线性变换的伸缩因子。

    1 描述

    Doraemon, a robot cat from the 21st century, has a lot of magic tools. And he is always helping others. Little Ken, a little kid in Wuhan University,
    is frequently teased by his classmates. So, Little Ken wants to be a big Ken, a strong Ken, instead of little Ken.
    One day Doraemon heard of that the cherry blossoms in Wuhan University are more beautiful than those in Japan, so Doraemon flied to China by
    his aircraft. While enjoying the blossoms, he happened to hear of Little Ken?s rough life. The kindhearted Doraemon decided to help Little Ken, you
    know,to be a big Ken.

    woj1014-1.PNG

    Doraemon picks out a flashlight from his pocket. The flashlight is one of his magic tools. All the objects illuminated by this flashlight will
    become much bigger than before. So Doraemon points the flashlight to Little Ken. At the moment that Doraemon wants to push the button, Little
    Ken cries, ?Wait a second!? Because he doubts this magic tool, Little Ken wants to test it first. He picks up a cubic and illuminates it.
    The cubic changes its shape, as the following figure shows:
    woj1014-2.PNG

    woj1014-3.PNG

    2 输入输出

    输入格式
    There are several test cases. In each test case a 3*3 matrix is given, representing the transform of the flashlight. All the numbers of the matrix are integers ranging from -100 to 100, inclusively.

    输出格式
    Output the volume of the object transformed from a unit cubic, round to 2 digits after the decimal point.

    3 样例

    样例输入
    1 0 1
    0 2 0
    -1 0 1

    1 0 0
    0 1 0
    0 0 1

    样例输出
    4.00
    1.00

    4 分析

    // 线性代数,行列式。。需要复习了
    //二阶三阶行列式求值可以用沙路法(对角线法则)
    //题意:给出的三阶行列式是变形公式,乘unit cubic
    //The coordinates of the eight vertices of the unit cubic are: (0, 0, 0),(0, 1, 0),(1, 1, 0),(1, 0, 0),(0, 0, 1),(0, 1, 1),
    //(1, 1, 1),(1, 0, 1).
    //Output the volume of the object transformed from a unit cubic, round to 2 digits after the decimal point.
    //小数点后2位。
    //然后算体积
    //https://www.zhihu.com/question/36966326 这题我没明白,看了资料说是行列式就是线性变换的伸缩因子,
    //原来的体积是1,经过矩阵的线性变换的体积就是1*矩阵行列式
    //可以设几个例子看确实是这样的
    //北大数学系的hzg说是在xyz三个维度拉长,比如行列式值为4,就是拉长4^(1/3),乘起来就是4

    //港大数学系的同学说就是积分换元(体积积分)
    体积积分.png
    体积积分2.png

    5 code

    #include<cstdio>
    #include<cmath>
    using namespace std;
    
    double x1;
    double x2,x3;
    double y11;
    double y2,y3,z1,z2,z3;
    
    int main()
    {
        while(scanf("%lf%lf%lf",&x1,&x2,&x3)==3)
        {
          scanf("%lf%lf%lf",&y11,&y2,&y3); 
          scanf("%lf%lf%lf",&z1,&z2,&z3);
          printf("%.2lf
    ",fabs(x1*(y2*z3-y3*z2)-y11*(x2*z3-x3*z2)+z1*(x2*y3-x3*y2)));//沙路法,对角线法则
        }
       return 0;  
    }
    
  • 相关阅读:
    mysql报错解决
    数据存储
    记录python接口自动化测试--把操作excel文件的方法封装起来(第五目)
    基础补充:使用xlrd模块读取excel文件
    记录python接口自动化测试--利用unittest生成测试报告(第四目)
    记录python接口自动化测试--pycharm执行测试用例时需要使用的姿势(解决if __name__ == "__main__":里面的程序不生效的问题)(第三目)
    记录python接口自动化测试--unittest框架基本应用(第二目)
    记录python接口自动化测试--requests使用和基本方法封装(第一目)
    连接数据后,当执行查询语句报错:ORA-01219: 数据库未打开: 仅允许在固定表/视图中查询
    通过运行一个tomcat容器来记录下初学docker常用的几个命令---容器篇
  • 原文地址:https://www.cnblogs.com/lqerio/p/13485308.html
Copyright © 2011-2022 走看看