Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	distance_table := [][]int{
		{0, 6, 13, 18, 23, 43, 58},
		{6, 0, 7, 12, 17, 37, 52},
		{13, 7, 0, 5, 10, 30, 45},
		{18, 12, 5, 0, 5, 25, 40},
		{23, 17, 10, 5, 0, 20, 35},
		{43, 37, 30, 25, 20, 0, 15},
		{58, 52, 45, 40, 35, 15, 0},
	}
	toll_table := [][]int{
		{0, 300, 500, 600, 700, 1350, 1650},
		{300, 0, 350, 450, 600, 1150, 1500},
		{500, 350, 0, 250, 400, 1000, 1350},
		{600, 450, 250, 0, 250, 850, 1300},
		{700, 600, 400, 250, 0, 600, 1150},
		{1350, 1150, 1000, 850, 600, 0, 500},
		{1650, 1500, 1350, 1300, 1150, 500, 0},
	}
	for scanner.Scan() {
		d, _ := strconv.Atoi(scanner.Text())
		if d == 0 {
			break
		}
		d--
		scanner.Scan()
		dbuf := strings.Split(scanner.Text(), " ")
		dh, _ := strconv.Atoi(dbuf[0])
		dm, _ := strconv.Atoi(dbuf[1])
		dtime := 100*dh+dm
		scanner.Scan()
		a, _ := strconv.Atoi(scanner.Text())
		a--
		scanner.Scan()
		abuf := strings.Split(scanner.Text(), " ")
		ah, _ := strconv.Atoi(abuf[0])
		am, _ := strconv.Atoi(abuf[1])
		atime := 100*ah+am
		toll := toll_table[d][a]
		if distance_table[d][a] <= 40 &&
			1730 <= dtime && dtime <= 1930 ||
			1730 <= atime && atime <= 1930 {
				toll = ((toll/2-1)/50+1)*50
		}
		fmt.Println(toll)
	}
}

C++: #include <iostream>
#include <cstdio>
using namespace std;

bool hangaku(int x, int y){
	int max=19*60+30, min=17*60+30;
	int n=x*60+y;

	if(min<=n && n<=max) return true;
	else return false;
}

int main(){
	//料金
	int p[8][8]={0};
	p[1][2]=300; p[1][3]=500; p[1][4]=600; p[1][5]=700; p[1][6]=1350; p[1][7]=1650;
	p[2][3]=350; p[2][4]=450; p[2][5]=600; p[2][6]=1150; p[2][7]=1500;
	p[3][4]=250; p[3][5]=400; p[3][6]=1000; p[3][7]=1350;
	p[4][5]=250; p[4][6]=850; p[4][7]=1300;
	p[5][6]=600; p[5][7]=1150;
	p[6][7]=500;     
	
	for(int i=1; i<8; ++i){
		for(int j=i+1; j<8; ++j){
			p[j][i]=p[i][j];
		}
	}
	
	//半額になるかどうか
	bool half[8][8];
	for(int i=0; i<8; ++i)
		for(int j=0; j<8; ++j)
			half[i][j]=true;
			
	half[1][6]=false; half[1][7]=false; half[2][7]=false; half[3][7]=false;
	half[6][1]=false; half[7][1]=false; half[7][2]=false; half[7][3]=false;
			
	//処理
	while(1){
		int inic, outic, h1, m1, h2, m2;
		
		scanf(" %d", &inic);
		if(inic==0) break;
		
		scanf(" %d %d", &h1, &m1);
		scanf(" %d", &outic);
		scanf(" %d %d", &h2, &m2);
	
		int price=p[inic][outic];
		if(hangaku(h1, m1) || hangaku(h2,m2)){
			price/=2;
			if(price%50!=0){
				price+=50-(price%50);	
			}
		}	
	
		printf("%d\n", price);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int s[7][7]={{0,300,500,600,700,1350,1650},
	     {6,0,350,450,600,1150,1500},
	     {13,7,0,250,400,1000,1350},
	     {18,12,5,0,250,850,1300},
	     {23,17,10,5,0,600,1150},
	     {43,37,30,25,20,0,500},
	     {58,52,45,40,35,15,0}};

int main(){
  int sc,sh,sm,ec,eh,em; 
  while(cin>>sc&&sc){
    cin>>sh>>sm>>ec>>eh>>em;
    int k=0,an=s[sc-1][ec-1],S=sh*100+sm,E=eh*100+em;
    if(S>E)E+=2400;
    if(S<=1730&&1730<=E)k++;
    if(S<=1930&&1930<=E)k++;
    if(S<=2400+1930&&2400+1930<=E)k++;
    if(s[ec-1][sc-1]<=40&&k==1)an/=2;
    if(an%50)an-=an%50,an+=50;
    cout<<an<<endl;
  }
  return 0;
}