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;  
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值