栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

zoj 3504 P

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

zoj 3504 P

#include <iostream>#include <math.h>#include <stdio.h>#include <complex>#include <vector>#include <string>#include <sstream>using namespace std;complex < double > g( string a ){int f = 1;string s = "", t = "";for( int i = 1 ; i+1 < a.size() ; i ++ )if( a[i] == ',' )f = 0;else if( f )s += a[i];elset += a[i];stringstream ss( s );double x, y;ss >> x;ss.clear();ss.str( t );ss >> y;return complex < double > ( x , y );}vector < complex < double > > f( string a ){vector < complex < double > > r;for( int i = 0 ; i < a.size() ; i ++ ){string s = "";while( i < a.size() && a[i] != ' ' )s += a[i], i ++;r.push_back( g( s ) );}return r;}double dis( complex < double > a , complex < double > b ){return sqrt( ( a.real() - b.real() ) * ( a.real() - b.real() ) + ( a.imag() - b.imag() ) * ( a.imag() - b.imag() ) );return sqrt( abs( a - b ) );}int main(){int n;string s, t, pp;vector < complex < double > > a, b;while( getline( cin , s ) , s.size() ){getline( cin , t );a = f( s );b = f( t );getline( cin , pp );stringstream ss( pp );double p = 0.0;ss >> p;double c = 0.0;for( int i = 0 ; i < a.size() ; i ++ )c += pow( dis( a[i] , b[i] ) , p );c = pow( c , 1./p );printf( "%.10lfn" , c );}}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/380119.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号