---
# System prepended metadata

title: Coding-frenzy CC-26 Reference code

---

# Coding-frenzy CC-26 Reference code
---
### CC-2601A
```cpp
#include<iostream>
using namespace std;
class Point{public:
   double m_x,m_y;
   Point(double x=0,double y=0):m_x(x),m_y(y){}//使用預設值，可代表0~2個參數的建構子
   Point operator-(Point b){return Point(m_x-b.m_x,m_y-b.m_y);}
};
istream& operator>>(istream &is,Point &a){return is>>a.m_x>>a.m_y;}
class Rectangle {
public :
	Point r_x,r_y;
	int height() {return abs((r_x-r_y).m_y);}
	int width () {return abs((r_x-r_y).m_x);}
};
istream& operator >> (istream &is,Rectangle &a){return is>>a.r_x>>a.r_y;}
ostream& operator << (ostream &os,Rectangle  a){return os<<a.width()<<' '<<a.height();}
int main(){
   int n;cin>>n;
   while(n--){
      Rectangle rec;cin>>rec;
      cout<<rec<<endl;
   }
   return 0;
}
```
### CC-2601B
```cpp
#include<iostream>
using namespace std;
class Fraction{public:
   int x,y;
   Fraction(int a=0,int b=0):x(a),y(b){}
   Fraction operator-(Fraction b){return Fraction(abs(x*b.y-y*b.x),y*b.y);}
};
istream& operator>>(istream &is,Fraction &a){char c;return is>>a.x>>c>>a.y;}
ostream& operator<<(ostream &os,Fraction  a){return os<<a.x<<"/"<<a.y;}

class Section{public:
	Fraction s_x,s_y;
	Fraction len() {return (s_x-s_y);}
   
};
istream& operator>>(istream &is,Section &a){
     return is>>a.s_x>>a.s_y;    
}
ostream& operator<<(ostream &os,Section a){
   return os<<a.len();
}

int main(){
   int n;cin>>n;
   while(n--){
      Section sec;cin>>sec;
      cout<<sec.s_x<<' '<<sec.s_y<<' ';
      cout<<sec<<endl;
   }
   return 0;
}
```
### CC-2602A
```cpp
#include<iostream>
#include<vector>
#include<numeric>
using namespace std;
class Point{public:
   double m_x,m_y;
   Point(double x=0,double y=0){m_x=x;m_y=y;}
   Point operator+(Point b){return Point(m_x+b.m_x,m_y+b.m_y);}
   Point operator/(int n)  {return Point(m_x/n,m_y/n)        ;}
};
istream& operator>>(istream &is,Point&a){return is>>a.m_x>>a.m_y;}
ostream& operator<<(ostream &os,Point&a){return os<<"("<<a.m_x<<","<<a.m_y<<")";}
class PVec{public:
   vector<Point> m_pts;//成員物件
   PVec (int n):m_pts(n){};
   Point sum() {return accumulate(m_pts.begin(),m_pts.end(),Point() );}
   Point avg() {return sum()/m_pts.size();}
};
istream& operator >> (istream &is,PVec&a) {
	for (int i=0; i<a.m_pts.size(); i++)
		is >> a.m_pts[i];
	return is;
}
ostream& operator << (ostream &os,PVec&a) {
	return os << "sum:" << a.sum() << endl
	          << "avg:" << a.avg() << endl;
}
int main(){
   int n;cin>>n;
   PVec pts(n);
   cin>>pts;
   cout<<pts;
   return 0;
}
```
### CC-2602B
```cpp
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class Frac{public:
  __int64 m_n,m_d;
  Frac(__int64 n=0,__int64 d=1):m_n(n),m_d(d){
    m_n /= __gcd(n,d);
    m_d /= __gcd(n,d);
  }
	Frac operator+ (Frac b) {return Frac(m_n*b.m_d+b.m_n*m_d,m_d*b.m_d);}
	Frac operator* (Frac b) {return Frac(m_n*b.m_n,m_d*b.m_d);}
	Frac operator/ (int n)	{return Frac(m_n,m_d*n);}
};
istream& operator >>(istream &is,Frac &a){
  char c;
  return is>>a.m_n>>c>>a.m_d;
}
ostream& operator <<(ostream &os,Frac a){return os<<a.m_n<<"/"<<a.m_d;}

class FVec{public:
	vector<Frac> m_vs;
	FVec() {};
	FVec(int n):m_vs(n){};
	Frac sum() {
		Frac tmp; 
		for(int i=0; i<m_vs.size(); i++) tmp = tmp + m_vs[i];
		return tmp;
	}
	Frac pro() {
		Frac tmp(1,1);
		for(int i=0; i<m_vs.size(); i++) tmp = tmp * m_vs[i];
		return tmp;
	}
	Frac avg() {return sum() / m_vs.size();}
};
istream& operator >>(istream &is,FVec &vs){
	
	for (int i=0; i<vs.m_vs.size(); i++) is >> vs.m_vs[i];
	return is;
}
int main(){
  int n; cin >> n;
  FVec a(n); cin >> a;
  cout<<a.sum()<<endl<<a.pro()<<endl<<a.avg()<<endl;
  return 0;
}
```
### CC-2603A
```cpp
#include<iostream>
#include<vector>
#include<numeric>
using namespace std;
class Point{
   double m_x,m_y;
public:
   Point(double x=0,double y=0):m_x(x),m_y(y){}
   Point operator+(Point b){return Point(m_x+b.m_x,m_y+b.m_y);}
   Point operator/(double b){return Point(m_x/b,m_y/b);}
   double& getter_x() {return m_x;}
   double& getter_y() {return m_y;}
};
istream& operator>>(istream &is,Point&a){
	return is >> a.getter_x() >> a.getter_y();
}
ostream& operator<<(ostream &os,Point&a){
	return os << '(' << a.getter_x() << ',' << a.getter_y() << ')';
}
class PVec{
   vector<Point> m_pts;
public:
   PVec(int n):m_pts(n){}
   int size() {return m_pts.size();}
   Point& operator[] (int k) {return m_pts[k];}
   Point sum(){return accumulate(m_pts.begin(),m_pts.end(),Point());}
   Point avg(){return sum()/m_pts.size();}
};
istream& operator>>(istream &is,PVec&a){
   for(int k=0;k<a.size();k++)is>>a[k];
   return is;
}
ostream& operator<<(ostream &os,PVec&a){
   return os<<"sum:"<<a.sum()<<endl<<"avg:"<<a.avg()<<endl;
}
int main(){
   int n;cin>>n;
   PVec pts(n);
   cin>>pts;
   cout<<pts<<endl;
   return 0;
}
```
### CC-2603B
```cpp
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;
class Fraction{public:
   int x,y;
   Fraction(int a=0,int b=1):x(a),y(b){
   		x /= __gcd(a,b);
   		y /= __gcd(a,b);
   }
         Fraction operator +( Fraction b){
                return  Fraction(x*b.y+y*b.x,y*b.y);
        }
         Fraction operator *( Fraction b){
                return  Fraction(x*b.x,y*b.y);
        }
         Fraction operator /(int b){
                return  Fraction(x,y*b);
        }
};
istream& operator>>(istream &is,Fraction &a){char c;return is>>a.x>>c>>a.y;}
ostream& operator<<(ostream &os,const Fraction &a){return os<<a.x<<"/"<<a.y;}

class FVec{
     vector<Fraction>fv;
public:
	FVec() {};
	FVec(int n):fv(n) {};
	FVec getsize(int n) {FVec a(n); return a;}
	int size() {return fv.size();}
	Fraction& operator[] (int i) {return fv[i];}
	Fraction sum() {
		return accumulate(fv.begin(),fv.end(),Fraction() ); 
	}
	Fraction pro() {
		Fraction b(1,1);
		for (int i=0; i<fv.size(); i++) b = b * fv[i];
		return b; 
	}
	Fraction avg() {
		return sum() / fv.size(); 
	}
};
istream& operator>>(istream &xis,FVec &a){
    int n; cin >> n; a = a.getsize(n);
	for (int i=0; i<a.size(); i++) xis >> a[i];
	return xis;
}
int main(){
  FVec a;cin>>a;
  cout<<a.sum()<<endl<<a.pro()<<endl<<a.avg()<<endl;
  return 0;
}
```
### CC-2604A
```cpp
#include<iostream>
#include<vector>
#include<numeric>
using namespace std;
class Point{
   double m_x,m_y;
public:
   Point(double x=0,double y=0):m_x(x),m_y(y){}
   Point operator+(Point b){return Point(m_x+b.m_x,m_y+b.m_y);}
   Point operator/(double b){return Point(m_x/b,m_y/b);}
   friend istream& operator >>(istream &is,Point &a);
   friend ostream& operator <<(ostream &is,Point &a);
};
istream& operator >>(istream &is,Point &a){return is>>a.m_x>>a.m_y;}
ostream& operator <<(ostream &os,Point &a){
   return os<<"("<<a.m_x<<","<<a.m_y<<")";
}
class PVec{
   vector<Point> m_pts;
public:
   PVec(int n):m_pts(n){}
   Point sum(){return accumulate(m_pts.begin(),m_pts.end(),Point());}
   Point avg(){return sum()/m_pts.size();}
   friend istream& operator>>(istream &is,PVec&a);
};
istream& operator>>(istream &is,PVec&a){
   for(int k=0;k<a.m_pts.size();k++) is>>a.m_pts[k];
   return is;
}
ostream& operator<<(ostream &os,PVec a){
   return os<<"sum:"<<a.sum()<<endl<<"avg:"<<a.avg()<<endl;
}
int main(){
   int n;cin>>n;
   PVec pts(n);
   cin>>pts;
   cout<<pts;
   return 0;
}
```
### CC-2604B
```cpp
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;
class Fraction{
   int x,y;
public:
   Fraction(int a=0,int b=1):x(a),y(b){
       x /= __gcd(a,b);
       y /= __gcd(a,b);
   }
   Fraction operator +( Fraction b){
       return  Fraction(x*b.y+y*b.x,y*b.y);
   }
   Fraction operator *( Fraction b){
       return  Fraction(x*b.x,y*b.y);
   }
   Fraction operator /(int b){
       return  Fraction(x,y*b);
   }
   friend istream& operator>>(istream &is,Fraction &a);
   friend ostream& operator<<(ostream &os,Fraction  a);
};
istream& operator>>(istream &is,Fraction &a){char c;return is>>a.x>>c>>a.y;}
ostream& operator<<(ostream &os,Fraction  a){return os<<a.x<<"/"<<a.y;}

class FVec{
   vector<Fraction>fv;
public:
	FVec() {};
	FVec(int n):fv(n) {};
   friend istream& operator>>(istream &xin,FVec &a);
   Fraction sum() {
       return accumulate(fv.begin(),fv.end(),Fraction() );
   }
   Fraction pro() {
       Fraction b(1,1);
       for (auto &n : fv) b = b * n;
       return b;
   }
   Fraction avg() { 
       return sum() / fv.size(); 
   }
};
istream& operator>>(istream &xin,FVec &a){
	int n; cin >> n; a = FVec(n);
	for (int i=0; i<a.fv.size(); i++) cin >> a.fv[i];
	return xin;
}
int main(){
  FVec a;cin>>a;
  cout<<a.sum()<<endl<<a.pro()<<endl<<a.avg()<<endl;
  return 0;
}
```
### CC-2605A
```cpp
#include<iostream>
#include<vector>
#include<numeric>
using namespace std;
class Point{
   double m_x,m_y,m_z;
public:
   Point(double x=0,double y=0):m_x(x),m_y(y){}
   Point operator+(const Point& b) const{
      return Point(m_x+b.m_x,m_y+b.m_y); 
   }
   Point operator/(double b) const{return Point(m_x/b,m_y/b);}//why can no const
   friend istream& operator>>(istream &is,Point&a);
   friend ostream& operator<<(ostream &os,const Point&a);
};
istream& operator>>(istream &is,Point&a){return is>>a.m_x>>a.m_y;}
ostream& operator<<(ostream &os,const Point&a){
   return os<<"("<<a.m_x<<","<<a.m_y<<")";
}
class PVec{
   vector<Point> m_pts;
public:
   PVec(int n):m_pts(n){}
   Point sum() const{
      return accumulate(m_pts.begin(),m_pts.end(),Point());
   }
   Point avg() const{return sum()/m_pts.size();}
   friend istream& operator>>(istream &,PVec&);
   friend ostream& operator<<(ostream &,const PVec&);
};
istream& operator>>(istream &is,PVec&a){
   for(int k=0;k<a.m_pts.size();k++)cin>>a.m_pts[k];
   return is;
}
ostream& operator<<(ostream &os,const PVec &a){
   return os<<"sum:"<<a.sum()<<endl<<"avg:"<<a.avg()<<endl;
}
int main(){
   int n;cin>>n;
   PVec pts(n);
   cin>>pts;
   cout<<pts;
   return 0;
}
```
### CC-2605B
```cpp
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class Fraction{
   int x,y;
   public:
   Fraction(int a=0,int b=1):x(a),y(b){
       x /= __gcd(a,b); y /= __gcd(a,b);
   }
         Fraction operator +(const Fraction& b)const{
                return  Fraction(x*b.y+y*b.x,y*b.y);
        }
         Fraction operator *(const Fraction& b)const{
                return  Fraction(x*b.x,y*b.y);
        }
         Fraction operator /(int b)const{
                return  Fraction(x,y*b);
        }
	friend istream& operator >>(istream& is,Fraction& a);
	friend ostream& operator <<(ostream& is,const Fraction& a);
};
istream& operator >>(istream& is,Fraction& a) {
	char c;
	return is >> a.x >> c >> a.y;
}
ostream& operator <<(ostream& os,const Fraction& a) {
	return os << a.x << '/' << a.y;
}
class FVec{
   vector<Fraction>fv;
public:
	FVec() {}
	FVec(int n):fv(n) {}
        Fraction tol()const{
                Fraction ans=fv[0];
                for(int i=1;i<fv.size();i++){
                        ans=ans+fv[i];
                }
                return ans;
        }
        Fraction cross()const{
                Fraction ans=fv[0];
                for(int i=1;i<fv.size();i++){
                        ans=ans*fv[i];
                }
                return ans;
        }
        Fraction avg()const{
                return tol()/fv.size();
        }
	friend istream& operator >>(istream& is,FVec& a);
	
};
istream& operator >>(istream& is,FVec& a) {
	int n; is >> n; a = FVec(n);
	for (int i=0; i<a.fv.size(); i++) is >> a.fv[i];
	return is;	
}
ostream& operator <<(ostream& os,const FVec& a) {
	return os << a.tol() << endl << a.cross() << endl << a.avg() << endl;
}
int main(){
   FVec a;cin>>a;
   cout<<a;
   return 0;
}
```
### CC-2606A
```cpp
#include<iostream>
#include<vector>
#include<numeric>
using namespace std;
class Point{
   double m_x,m_y;
public:
   Point(double x=0,double y=0):m_x(x),m_y(y){}
   Point operator+(const Point b)const{return Point(m_x+b.m_x, m_y+b.m_y);}
   Point operator/(double b)const{return Point(m_x/b,m_y/b);}
   friend istream& operator>>(istream &is,Point&a);
   friend ostream& operator<<(ostream &os,const Point&a);
};
istream& operator>>(istream &is,Point&a){return is>>a.m_x>>a.m_y;}
ostream& operator<<(ostream &os,const Point&a){
   return os<<"("<<a.m_x<<","<<a.m_y<<")";
}
class PVec:vector<Point>{
public:
   PVec(int n):vector<Point>(n) {}
   Point sum() const{return accumulate(begin(),end(),Point() );}
   Point avg() const{return sum() / size();}
   friend istream& operator>>(istream &,PVec&);
   friend ostream& operator<<(ostream &,const PVec&);
};
istream& operator>>(istream &is,PVec&a){
   for(int k=0;k<a.size();k++)cin>>a[k];
   return is;
}
ostream& operator<<(ostream &os,const PVec &a){
   return os<<"sum:"<<a.sum()<<endl<<"avg:"<<a.avg()<<endl;
}
int main(){
   int n;cin>>n;
   PVec pts(n);
   cin>>pts;
   cout<<pts;
   return 0;
}
```
### CC-2606B
```cpp
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class Frac{public:
  int m_x,m_y;
  Frac(int n=0,int d=1):m_x(n),m_y(d){
     int gcd = __gcd(n,d); if(gcd<0) gcd *= -1;
     m_x /= gcd; m_y /= gcd;
  }
  Frac operator+(const Frac& b) const{
   	 return Frac(m_x*b.m_y+b.m_x*m_y,m_y*b.m_y);
  } 
  Frac operator-(const Frac& b) const{
     return Frac(m_x*b.m_y-b.m_x*m_y,m_y*b.m_y);
  }
  Frac operator*(const Frac& b) const{return Frac(m_x*b.m_x,m_y*b.m_y);}
  Frac operator/(const Frac& b) const{return Frac(m_x*b.m_y,m_y*b.m_x);}
};
istream& operator>>(istream &xin,Frac &a){
	char c;
	return xin >> a.m_x >> c >> a.m_y;
}
ostream& operator<<(ostream &xout,const Frac &a){
	return xout << a.m_x << '/' << a.m_y;
}
int main(){
  Frac a,b;
  cin>>a>>b;
  cout<<a+b<<endl;
  cout<<a-b<<endl;
  cout<<a*b<<endl;
  cout<<a/b<<endl;
  return 0;
}
```
### CC-2607A
```cpp
#include<iostream>
#include<vector>
#include<numeric>
using namespace std;
class Point{
   double m_x,m_y;
   static int pop;
public:
   Point (double a=0,double b=0):m_x(a),m_y(b) {pop++;}
   Point (const Point& b):m_x(b.m_x),m_y(b.m_y) {pop++;}
   ~Point() {pop--;}
   static int Population() {return pop;}
   Point operator+(const Point& b)const{return Point(m_x+b.m_x,m_y+b.m_y);}
   Point operator/(double b)const{return Point(m_x/b,m_y/b);}
   friend istream& operator>>(istream &is,Point &a);
   friend ostream& operator<<(ostream &os,const Point&a);
};
int Point::pop;
istream& operator>>(istream &is,Point&a){return is>>a.m_x>>a.m_y;}
ostream& operator<<(ostream &os,const Point&a){
   return os<<"("<<a.m_x<<","<<a.m_y<<")";
}
class PVec:public vector<Point>{
   public:
   PVec(int n):vector<Point>(n){}
   Point sum()const{return accumulate(begin(),end(),Point() );}
   Point avg()const{return sum()/size();}
};
istream& operator>>(istream &is,PVec&a){
   for(int k=0;k<a.size();k++)is>>a[k];
   return is;
}
ostream& operator<<(ostream &os,const PVec &a){
   return os<<"sum:"<<a.sum()<<endl<<"avg:"<<a.avg()<<endl;
}
int main(){
   {
   	int n;cin>>n;
	PVec pts(n);cin>>pts;
	cout<<pts<<endl;
	cout<<Point::Population()<<endl;
   }
   cout<<Point::Population()<<endl;
   return 0;
}
```
### CC-2607B
```cpp
#include<iostream>
#include<vector>
#include<numeric>
using namespace std;
class Score{
   double m_x,m_y;
   static int s_popu;//靜態成員變數
public:
   static int Population() {return s_popu;}
   ~Score(){s_popu--;}
   Score(const Score &b):m_x(b.m_x),m_y(b.m_y){s_popu++;}
   Score(double x=0,double y=1):m_x(x),m_y(y){s_popu++;}
   Score operator+(const Score& b)const{
   	  double ia=m_x*b.m_y+b.m_x*m_y;	  
   	  double ib=m_y*b.m_y;
   	  return Score(ia,1);
   } 
   Score operator-(const Score& b)const{
      double ia=m_x*b.m_y-b.m_x*m_y;
   	  double ib=m_y*b.m_y;
   	  return Score(ia,ib);
   }
   Score operator*(const Score& b)const{return Score(m_x*b.m_x,m_y*b.m_y);}
   Score operator/(const Score& b)const{return Score(m_x*b.m_y,m_y*b.m_x);}
   friend istream& operator>>(istream &is,Score &a);
   friend ostream& operator<<(ostream &os,const Score&a);
};
int Score::s_popu;//靜態成員變數安排空間
istream& operator>>(istream &is,Score&a){return is>>a.m_x>>a.m_y;}
ostream& operator<<(ostream &os,const Score&a){
   return os<<a.m_x<<"/"<<a.m_y;
}
class FVec:public vector<Score>{
   public:
   FVec(int n):vector<Score>(n){}
   Score sum()const{return accumulate(begin(),end(),Score());}
   Score avg()const{return sum()/size();}
};
istream& operator>>(istream &is,FVec&a){
   for(int k=0;k<a.size();k++)is>>a[k];
   return is;
}
ostream& operator<<(ostream &os,const FVec &a){
   return os<<"sum:"<<a.sum()<<endl<<"avg:"<<a.avg()<<endl;
}
int main(){
   {
   	int n;cin>>n;
	FVec pts(n);cin>>pts;
	cout<<pts<<endl;
	cout<<Score::Population()<<endl;
   }
   cout<<Score::Population()<<endl;
   return 0;
}
```
### CC-2608A
```cpp
#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>
using namespace std;
class Point{
   double m_x,m_y;
public:
   Point(double x=0,double y=0):m_x(x),m_y(y){}
   
   Point operator+(const Point& b)const{return Point(m_x+b.m_x,m_y+b.m_y);}
   Point operator/(double b)const{   return Point(m_x/b,m_y/b);}
   
   operator double()const{return sqrt(m_x*m_x+m_y*m_y);}
   
   friend istream& operator>>(istream &is,Point&a);
   friend ostream& operator<<(ostream &os,const Point&a);
};
istream& operator>>(istream &is,Point&a){return is>>a.m_x>>a.m_y;}
ostream& operator<<(ostream &os,const Point&a){
   return os<<"("<<a.m_x<<","<<a.m_y<<")";
}
class PVec:public vector<Point>,public Point {
public:
   PVec(int n):vector<Point>(n){}
   Point sum()const{
       return accumulate(begin(),end(),Point() );
   }
   Point avg()const{
   		Point G = sum() / size() ;
   		(*(Point*)this) = G;  // this先轉乘Point*型態 再取地址的值(變成Point)
   		return G;
   }
   operator double()const{
       double ans=0;
       for(int i=0; i<size(); i++) ans += (*this)[i]; // (*this) == pts
       return ans;
   }
   friend istream& operator>>(istream &,PVec&);
   friend ostream& operator<<(ostream &,const PVec&);
};
istream& operator>>(istream &is,PVec&a){
   for(int k=0;k<a.size();k++)is>>a[k];
   return is;
}
ostream& operator<<(ostream &os,const PVec &a){
   return os<<"sum:"<<a.sum()<<endl
            <<"avg:"<<a.avg()<<endl;
}
int main(){
   int n;cin>>n;
   PVec pts(n);cin>>pts;
   cout<<pts<<endl;//第一型 PVec
   Point G=pts;cout<<G<<endl;//第二型 Point
   cout<<pts.size()<<endl;//第三型 vector<Point>
   cout<<(double)pts<<endl;//第三型 轉型為 double
   return 0;
}
```
### CC-2608B
```cpp
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;
class Frac{public:
  __int64 m_n,m_d;  
  Frac(__int64 n=0,__int64 d=1):m_n(n),m_d(d) {
      int gcd = __gcd(n,d); if(gcd<0) gcd *= -1;
      m_n /= gcd; m_d /= gcd;
  }
  void operator+=(const Frac& b){m_n=m_n*b.m_d+m_d*b.m_n;m_d*=b.m_d;}
  void operator*=(const Frac& b){m_n=m_n*b.m_n;m_d*=b.m_d;}	
  Frac operator/(int b)const{return  Frac(m_n,m_d*b);}
};
istream& operator>>(istream &is,Frac &a){
  char c;
  return is>>a.m_n>>c>>a.m_d;
}
ostream& operator<<(ostream &os,const Frac &a){return os<<a.m_n<<"/"<<a.m_d;}
class FVec:public vector<Frac>{
  vector <Frac> m_vs;
public:
  Frac sum() const{
  	Frac b;
  	for (auto &n : m_vs) b += n;
  	return Frac(b.m_n,b.m_d);
  }
  Frac pro() const{
  	Frac b(1,1);
  	for (auto &n : m_vs) b *= n;
  	return Frac(b.m_n,b.m_d);
  }
  Frac avg() const{
  	return sum() / m_vs.size();
  }
  friend istream& operator>>(istream &is,FVec &vs);
};
istream& operator >>(istream &is,FVec &vs){
  int n;is>>n;Frac v;
  while(n--){is>>v;vs.m_vs.push_back(v);}
  return is;
}
int main(){
  FVec a;cin>>a;
  cout<<a.sum()<<endl<<a.pro()<<endl<<a.avg()<<endl;
  return 0;
}
```
### CC-2609A
```cpp
#include<iostream>
using namespace std;
class Matrix {
	int ma,mb,mc,md;
public:
	Matrix() {}
	Matrix(int a, int b, int c, int d):ma(a),mb(b),mc(c),md(d) {}
	Matrix operator+ (const Matrix& b) const{
		return Matrix(ma+b.ma, mb+b.mb, mc+b.mc, md+b.md);
	}
	Matrix operator- (const Matrix& b) const{
		return Matrix(ma-b.ma, mb-b.mb, mc-b.mc, md-b.md);
	}
	Matrix operator* (const Matrix& b) const{
		return Matrix( ma*b.ma + mb*b.mc,
					   ma*b.mb + mb*b.md,
					   mc*b.ma + md*b.mc,
					   mc*b.mb + md*b.md 
					  );
	}
	friend istream& operator >>(istream& is,Matrix& mt);
	friend ostream& operator <<(ostream& os,const Matrix& m);
};
istream& operator >>(istream& is,Matrix& m) {
	return is >> m.ma >> m.mb >> m.mc >> m.md; 
}
ostream& operator <<(ostream& os,const Matrix& m) {
	return os<<' '<<m.ma<<' '<<m.mb<<endl<<' '<<m.mc<<' '<<m.md<<endl; 
}
int main(){
   Matrix a,b;cin>>a>>b;
   cout<<"a:"<<endl<<a<<endl;
   cout<<"b:"<<endl<<b<<endl;
   cout<<"a+b:"<<endl<<a+b<<endl;
   cout<<"a-b:"<<endl<<a-b<<endl;
   cout<<"a*b:"<<endl<<a*b<<endl;
   return 0;
}
```
### CC-2609B
```cpp=
#include <iostream>
using namespace std;
class matrix{
	int *data;
	int mn;
public:
	matrix(int n) {mn=n; data=new int[n*n];}
	
	matrix operator +(matrix m){
		matrix a(mn);
		for(int i=0;i<mn*mn;i++) {
			a.data[i] = data[i] + m.data[i] ;
		}
		return a;
	}
	matrix operator -(matrix m){
		matrix a(mn);
		for(int i=0;i<mn*mn;i++) {
			a.data[i] = data[i] - m.data[i];
		}
		return a;
	}
	matrix operator *(matrix m){	
		matrix a(mn);
		for (int i=0; i<mn*mn; i++) a.data[i]=0;
		for(int i=0;i<mn;i++) {
			for(int j=0; j<mn; j++) {
				for(int k=0; k<mn; k++) {
					a.data[i*mn+j] += data[i*mn+k]*m.data[mn*k+j];
				}
			}
		}
		return a;
	}
	friend istream &operator>>(istream &is,matrix &c);
    friend ostream& operator<<(ostream& os,const matrix& c);
};
istream &operator>>(istream &is,matrix &c){
	for(int i=0;i<c.mn*c.mn;i++)is>>c.data[i];
	return is;
}
ostream& operator<<(ostream& os,const matrix& c){
  	for(int i=0;i<c.mn*c.mn;i++){
  		if(i!=0 &&i%c.mn==0)os<<endl;
  		os<<c.data[i]<<" ";  		
  	}
  	os<<endl;
	return os;
}
int main(){
	int n; cin>>n;
	matrix a(n);
	matrix b(n);
	cin>>a>>b;
	cout<<a+b<<endl;
	cout<<a-b<<endl;
	cout<<a*b<<endl;

}
```
### CC-2610A
```cpp
#include <iostream>
#include <cmath>
using namespace std;
class Point{
   double m_x,m_y;
public:
   Point(double x=0,double y=0):m_x(x),m_y(y){}
   Point operator+(const Point b)const{return Point(m_x+b.m_x,m_y+b.m_y);}
   Point operator*(double b)const{return Point(m_x*b,m_y*b);}
   Point operator/(double b)const{return operator*(1/b);}
   Point operator-(const Point &a)const{return operator+(a*(-1.));}
   operator double()const{return sqrt(m_x*m_x+m_y*m_y);}
   friend istream& operator>>(istream &is,Point&a);
   friend ostream& operator<<(ostream &os,const Point&a);
};
istream& operator>>(istream &is,Point&a){return is>>a.m_x>>a.m_y;}
ostream& operator<<(ostream &os,const Point&a){
   return os<<"("<<a.m_x<<","<<a.m_y<<")";
}
class Triangle {
	Point A,B,C;
public:
	Triangle() {}
	
	Point G() const{return (A+B+C) / 3;}
	Point I() const{
		double a = B-C; double b = C-A; double c = B-A;
		return (A*a+B*b+C*c) / (a+b+c);
	}
	
	friend istream& operator  >>(istream& is, Triangle& t);
	friend ostream& operator <<(ostream& os, const Triangle& t);
};
istream& operator >>(istream& is, Triangle& t) {
	return is >> t.A >> t.B >> t.C;
}
ostream& operator <<(ostream& os, const Triangle& t) {
	return os << "G:" << t.G() << endl << "I:" << t.I() ;
}
int main(){
   Triangle tri;cin>>tri;
   cout<<tri<<endl;
   return 0;
}
```
### CC-2610B (no code)

**本題爆炸不寫(\*ﾟ∀ﾟ\*)**

### CC-26D01
```cpp=
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
class Complex{public:
   double x,y;
   Complex(double a=0,double b=0):x(a),y(b){}
   Complex operator+(const Complex& p)const{return Complex(x+p.x,y+p.y);}
   Complex operator*(const Complex& p)const{return Complex(x*p.x-y*p.y,y*p.x+x*p.y);}
   Complex operator /(double b){return Complex(x/b,y/b);}
};
istream &operator>>(istream &is,Complex &c){
        char c1,c2;
        is>>c.x>>c1>>c.y>>c2;
        if(c1=='-')c.y*=-1;
        return is;
}
ostream& operator<<(ostream& os,const Complex& c){
        if(c.y==0)os<<c.x;
        else if(c.x==0)os<<c.y<<"i";
        else if(c.y<0) os<<c.x<<c.y<<"i";
        else os<<c.x<<"+"<<c.y<<"i";
   return os;
}
class CVec:public vector<Complex>,public Complex{
public:
    //CVec(int n):vector<Complex>(n) {}
    Complex tol() const{
    	Complex b; 
    	for(auto &n : (*this) )
    		b = b + n;
    	return b;	
    }
    Complex cross() const{
    	Complex b = (*this)[0]; 
    	for(int i=1; i<size(); i++)
    		b = b * (*this)[i];
    	return b;	
    }
    Complex avg() const{
    	return tol() / size();
    }
	friend istream& operator>>(istream &is,CVec &a);
};
istream& operator>>(istream &is,CVec &a){
     Complex b; cin >> b;
     a.push_back(b);
     return is ;
}
int main(){
   int n;cin>>n;
   CVec c;
   while(n--){
      cin>>c;
   }
   cout<<"sum:"<<c.tol()<<endl;
   cout<<"Cross product:"<<c.cross()<<endl;
   cout<<"avg:"<<c.avg()<<endl;
   return 0;
}
```
### CC-26D02
```cpp=
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
class Complex{public:
   double x,y;
   Complex(double a=0,double b=0):x(a),y(b){}
   Complex operator+(const Complex& p)const{return Complex(x+p.x,y+p.y);}
   Complex operator*(const Complex& p)const{return Complex(x*p.x-y*p.y,y*p.x+x*p.y);}
   Complex operator /(double b){return Complex(x/b,y/b);}
};
istream &operator>>(istream &is,Complex &c){
                 char c1,c2;
                                        is>>c.x>>c1>>c.y>>c2;
                 if(c1=='-')c.y*=-1;
        return is;
}
ostream& operator<<(ostream& os,const Complex& c){
        if(c.y==0)os<<c.x;
                 else if(c.x==0)os<<c.y<<"i";
                 else if(c.y<0) os<<c.x<<c.y<<"i";
        else os<<c.x<<"+"<<c.y<<"i";
   return os;
}
class CVec{
   vector<Complex>cv;
   public:
		
        void input(Complex &c) {
           cv.push_back(c);
        }
        Complex tol() const{
                Complex ans=cv[0];
                for(int i=1;i<cv.size();i++){
                        ans=ans+cv[i];
                }
                return ans;
        }
        Complex cross() const{
                Complex ans=cv[0];
                for(int i=1;i<cv.size();i++){
                        ans=ans*cv[i];
                }
                return ans;
        }
        Complex avg() const{
                return tol()/cv.size();
        }        
};
istream& operator>>(istream &is,CVec &a){
        Complex c;
        is>>c;
        a.input(c);
   return is;
}
ostream& operator<<(ostream &os,const CVec&a){
    return os << "sum:"			 << a.tol()   <<endl
    		  << "Cross product:"<< a.cross() <<endl
    		  << "avg:" 		 << a.avg()   <<endl;
}
int main(){
   int n;cin>>n;
   CVec c;
   while(n--){
      cin>>c;
   }
   cout<<c<<endl;
   return 0;
}
```
### CC-26D03
```cpp=
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
class Complex{public:
   double x,y;
   Complex(double a=0,double b=0):x(a),y(b){}
   Complex operator+(Complex& p){return Complex(x+p.x,y+p.y);}
   Complex operator*(Complex& p){return Complex(x*p.x-y*p.y,y*p.x+x*p.y);}
   Complex operator /(double b){return Complex(x/b,y/b);}
};
istream &operator>>(istream &is,Complex &c){
                 char c1,c2;
                                        is>>c.x>>c1>>c.y>>c2;
                 if(c1=='-')c.y*=-1;
        return is;
}
ostream& operator<<(ostream& os,const Complex& c){
        if(c.y==0)os<<c.x;
                 else if(c.x==0)os<<c.y<<"i";
                 else if(c.y<0) os<<c.x<<c.y<<"i";
        else os<<c.x<<"+"<<c.y<<"i";
   return os;
}
class CVec{
        vector<Complex>cv;
public:
        Complex tol(){
                Complex ans=cv[0];
                for(int i=1;i<cv.size();i++){
                        ans=ans+cv[i];
                }
                return ans;
        }
        Complex cross(){
                Complex ans=cv[0];
                for(int i=1;i<cv.size();i++){
                        ans=ans*cv[i];
                }
                return ans;
        }
        Complex avg(){
                return tol()/cv.size();
        }
        friend istream& operator>>(istream &is,CVec &a);        
};
istream& operator>>(istream &is,CVec &a){
        Complex c;
        is>>c;
        a.cv.push_back(c);
   return is;
}

int main(){
   int n;cin>>n;
   CVec c;
   while(n--){
      cin>>c;
   }
   cout<<"sum:"<<c.tol()<<endl;
   cout<<"Cross product:"<<c.cross()<<endl;
   cout<<"avg:"<<c.avg()<<endl;
   return 0;
}
```
### CC-26D04
```cpp=
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
class Complex{
   double x,y;
   public:
   Complex(double a=0,double b=0):x(a),y(b){}
   Complex operator+(Complex p){return Complex(x+p.x,y+p.y);}
   Complex operator*(Complex p){return Complex(x*p.x-y*p.y,y*p.x+x*p.y);}
   Complex operator /(double b){return Complex(x/b,y/b);}
   friend istream &operator>>(istream &is,Complex &c);
   friend ostream& operator<<(ostream& os,const Complex& c);
};
istream &operator>>(istream &is,Complex &c){
                 char c1,c2;
                 is>>c.x>>c1>>c.y>>c2;
                 if(c1=='-')c.y*=-1;
        return is;
}
ostream& operator<<(ostream& os,const Complex& c){
        if(c.y==0)os<<c.x;
        else if(c.x==0)os<<c.y<<"i";
        else if(c.y<0) os<<c.x<<c.y<<"i";
        else os<<c.x<<"+"<<c.y<<"i";
   return os;
}
class CVec{
   vector<Complex>cv;
   public:
        Complex tol() const{
                Complex ans=cv[0];
                for(int i=1;i<cv.size();i++){
                        ans=ans+cv[i];
                }
                return ans;
        }
        Complex cross()const{
                Complex ans=cv[0];
                for(int i=1;i<cv.size();i++){
                        ans=ans*cv[i];
                }
                return ans;
        }
        Complex avg() const{
                return tol()/cv.size();
        }
		friend istream& operator>>(istream &is,CVec &a);
		friend ostream& operator<<(ostream &os,const CVec&a);
};
istream& operator>>(istream &is,CVec &a){
        Complex c;
        is>>c;
        a.cv.push_back(c);
   return is;
}
ostream& operator<<(ostream &os,const CVec&a){
		os<<"sum:"<<a.tol()<<endl;
        os<<"Cross product:"<<a.cross()<<endl;
        os<<"avg:"<<a.avg()<<endl;
        return os;
}
int main(){
   int n;cin>>n;
   CVec c;
   while(n--){
      cin>>c;
   }
   cout<<c<<endl;
   return 0;
}
```
### CC-26D05
```cpp=
#include <iostream>
#include <cmath>
using namespace std;

class Complex{public:
   double x,y;
   Complex(double a=0,double b=0):x(a),y(b){}
   Complex operator-(Complex b){return Complex(abs(x-b.x),y-b.y);}
   operator double() {return sqrt(x*x+y*y);}
};
istream &operator>>(istream &is,Complex &c){
	char c1,c2;
	is>>c.x>>c1>>c.y>>c2;
	if(c1=='-')c.y*=-1;
	return is;
}
ostream& operator<<(ostream &os,const Complex &a){return os<<a.x<<"/"<<a.y;}

class Arrow{
	Complex x,y;
public:
    
    double len() {return x - y;} 
	friend istream& operator>>(istream &is,Arrow &a);
};
istream& operator>>(istream &is,Arrow &a){
	return is >> a.x >> a.y;
}

int main(){
   int n;cin>>n;
   while(n--){
      Arrow ar;cin>>ar;
      cout<<ar.len()<<endl;
   }
   return 0;
} 
```
