WOJ1014-Doraemon's Flashlight

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:

Little Ken realizes that the flashlight is actually processing a linear transform in the 3D Euclid Space. That means, given a 3*3 matrix A,
for example,

If a point?s original coordinate is, for instance, (1, 2, 3), then after the illuminated by the flashlight, the point moves to (4, 4, 2). That
is because the transform obeys the rule of a matrix multiplies a vector, as follows:

Now, given a matrix A, which represents the transform by the flashlight, your mission is to calculate the volume of the object that transformed
from a 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).
If the new object?s eight vertices become (0, 0, 0),(1, 0, -1),(1, 2, -1),(0, 2, 0),(1, 0, 1),(2, 0 , 0),(2, 2, 0),(1, 2, 1).
And the volume of the new object is 4.

输入格式

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.

样例输入

1 0 1
0 2 0
-1 0 1

1 0 0
0 1 0
0 0 1

样例输出

4.00
1.00

求3阶行列式的值,沙路法

#include<stdio.h>  
#include<stdlib.h>  
#include<math.h> 
int main(){
	float a[3][3]={0},volumn;  
   	int i,j;  
  	while(scanf("%f",&a[0][0])!=EOF){  
    	for(i=0;i<3;i++){  
      		if(i==0){  
        		for(j=1;j<3;j++)  
         		scanf("%f",&a[i][j]);  
      		}  
      		if(i!=0){  
      			for(j=0;j<3;j++)  
       			scanf("%f",&a[i][j]);  
       		}  
    	}  
    volumn=abs(a[0][0]*a[1][1]*a[2][2]+a[1][0]*a[2][1]*a[0][2]+a[2][0]*a[1][2]*a[0][1]-(a[2][0]*a[1][1]*a[0][2]  
    +a[0][1]*a[1][0]*a[2][2]+a[0][0]*a[2][1]*a[1][2]));  
    printf("%.2f\n",volumn);  
	}
	return 0;  
}


全部评论

相关推荐

不愿透露姓名的神秘牛友
07-10 11:45
你不要过来啊啊啊啊啊啊啊
码农索隆:对面:“今天你不面也得面”
点赞 评论 收藏
分享
头顶尖尖的程序员:我也是面了三四次才放平心态的。准备好自我介绍,不一定要背熟,可以记事本写下来读。全程控制语速,所有问题都先思考几秒,不要急着答,不要打断面试官说话。
点赞 评论 收藏
分享
zYvv:双一流加大加粗再标红,然后广投。主要是获奖荣誉不够,建议开始不用追求大厂,去别的厂子刷下实习。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务