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:



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]='\0'; //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]='\0'; //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.

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:

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

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



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\n",fabs(x1*(y2*z3-y3*z2)-y11*(x2*z3-x3*z2)+z1*(x2*y3-x3*y2)));//沙路法,对角线法则
}
return 0;
}

最新文章

  1. matlab更改打开时候默认路径
  2. 推荐几个Web前端开发实用的Chrome插件
  3. 3.多线程NSOperation
  4. 【转】【编码】ANSI,ASCII,Unicode,UTF8之一
  5. JSOI球形空间产生器 (高斯消元)
  6. android L 新控件侧滑菜单DrawerLayout 使用教程
  7. mp3 音频 音乐 tag ID3 ID3V1 ID3V2 标签 读取信息 获得图片 jpeg bmp 图片转换等
  8. 50+ 响应式的Prestashop电商主题
  9. MVC初学 - The type or namespace name &#39;DbContext&#39; could not be found
  10. 吃透C#集合~大话目录
  11. vivi虚拟摄像头驱动程序
  12. 美国康奈尔大学BioNB441元胞自动机MATLAB应用
  13. Linux/Android多点触摸协议
  14. 高可用-mysql安装,双主模式+keepalived
  15. URI ,URL 和 URN
  16. JavaScript——JS屏蔽F12和右键
  17. React入门——制作一个TodoList App
  18. mySQL 教程 第2章 安装和介绍mySQL
  19. 剑指offer三十四之第一个只出现一次的字符
  20. Linux系统初学-第三课 Linux网络配置1

热门文章

  1. kafka(一)入门
  2. AQS之ReentrantReadWriteLock写锁
  3. Sgu149 Computer Network
  4. 【Python】中国有哪些同名的省市县?
  5. 页面切换提速30%!京东商城APP首屏耗时监控及优化实践
  6. Golang拼接字符串的5种方法及其效率_Chrispink-CSDN博客_golang 字符串拼接效率 https://blog.csdn.net/m0_37422289/article/details/103362740
  7. MapReduce过程源码分析
  8. QR Code Error Correction
  9. 【Python网络编程】epoll用法
  10. LDAP学习