text stringlengths 49 983k |
|---|
#include<iostream>
using namespace std;
int pow(int x){
return x*x;
}
int main(){
int a,b,c;
int ans1=0;
int ans2=0;
char ch;
while(cin>>a>>ch>>b>>ch>>c){
if(pow(a)+pow(b)==pow(c))ans1++;
else if(a==b)ans2++;
}
cout<<ans1<<endl<<ans2<<endl;
} |
#include<iostream>
using namespace std;
int main(){
int l1,l2,l3,ans1,ans2;
char a;
ans1 = 0; ans2 = 0;
while(cin >> l1 >>a >>l2 >>a>>l3){
if(l1 == l2)
ans2++;
if(l1*l1 + l2*l2 == l3*l3)
ans1++;
}
cout << ans1 << endl << ans2 << endl;
} |
#include<bits/stdc++.h>
using namespace std;
int a,b,c,ans,ans2;
int main(){
while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
if(a*a+b*b==c*c)ans++;
if(a==b)ans2++;
}
cout<<ans<<endl<<ans2<<endl;
return 0;
} |
#include<stdio.h>
int main(){
int a, b, c, nrhombo = 0, nrectangle = 0;
while ( scanf("%d,%d,%d", &a, &b, &c) != EOF ) {
if ( a == b ) nrhombo++;
else if ( a*a + b*b == c*c ) nrectangle++;
}
printf("%d\n%d\n", nrectangle, nrhombo);
} |
#include <cstdio>
int main()
{
int a, b, c, c1, c2;
c1 = c2 = 0;
while (scanf("%d,%d,%d", &a, &b, &c) != EOF){
if (c * c - (a * a + b * b) == 0){
c1++;
}
if (a == b){
c2++;
}
}
printf("%d\n%d\n", c1, c2);
return 0;
} |
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
int a,b,c,h=0,s=0;
while(scanf("%d,%d,%d",&a,&b,&c)!=EOF) {
if (a==b) h++;
if (a*a+b*b==c*c) s++;
}
cout << s << endl << h << endl;
return 0;
} |
#include <cstdio>
int main(){
int a,b,c,n=0,m=0;
while(~scanf("%d,%d,%d",&a,&b,&c)){
if(a*a+b*b==c*c) n++;
if(a==b) m++;
}
printf("%d\n%d\n",n,m);
} |
#include<iostream>
using namespace std;
int a, b, c, d, e; char f;
int main() {
while (cin >> a >> f >> b >> f >> c) {
if (a*a + b*b == c*c) { d++; }
if (a == b) { e++; }
}
cout << d << endl << e << endl;
} |
//48
#include<iostream>
using namespace std;
int main(){
int cho=0,hishi=0;
for(int a,b,c;((cin>>a).ignore()>>b).ignore()>>c;){
hishi+=a==b;
cho+=c*c==a*a+b*b;
}
cout<<cho<<endl<<hishi<<endl;
return 0;
} |
#include<iostream>
using namespace std;
int main(void){
int a,b,c;
int count_a=0,count_b=0;
char x;
while(cin >> a >> x >> b >> x >>c){
if(a*a + b*b == c*c) count_a++;
else if(a == b) count_b++;
}
cout << count_a << endl;
cout << count_b << endl;
}
|
#include <iostream>
using namespace std;
int main()
{
int a, b, c, n = 0, m = 0;
char t;
while (1)
{
cin >> a;
if (cin.eof()) break;
cin >> t >> b >> t >> c;
if (a*a + b*b == c*c) n++;
if (a == b) m++;
}
cout << n << endl << m << endl;
} |
#include <iostream>
using namespace std;
int main(void)
{
int a,b,c;
int rec=0;
int loz=0;
while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
if(a==b) loz++;
if(a*a+b*b==c*c) rec++;
}
cout << rec << endl;
cout << loz << endl;
return 0;
} |
#include<iostream>
int main(){
int a,b,c;
char dummy;
int t=0, h=0;
while(std::cin>>a>>dummy>>b>>dummy>>c){
if(a == b)h++;
if((a*a+b*b)==c*c)t++;
}
std::cout<<t<<std::endl;
std::cout<<h<<std::endl;
return 0;
} |
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
int rect1 = 0;
int rect2 = 0;
int a, b, c;
while(~scanf("%d,%d,%d", &a, &b, &c)){
if(a*a + b*b == c*c){
rect1++;
}
if(a == b){
rect2++;
}
}
cout << rect1 << endl;
cout << rect2 << endl;
return 0;
} |
#include<iostream>
using namespace std;
int main(void)
{
int a,b,c;
char d;
int t,h;
t=h=0;
while(cin>>a>>d>>b>>d>>c)
{
if(a*a+b*b==c*c)
{
t++;
}
if(a==b)
{
h++;
}
}
cout<<t<<endl<<h<<endl;
} |
#include<iostream>
using namespace std;
int main()
{
int list[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 in,out,h,m,start,end,fee;
bool half;
while(cin>>in,in){
cin>>h>>m;
start=100*h+m;
cin>>out>>h>>m;
end=100*h+m;
if(in>out)swap(in,out);
in--;out--;
if( (1730<=start && start<=1930) || (1730<=end && end<=1930) )half=true;
else half=false;
if(list[out][in]>40)half=false;
fee=list[in][out];
if(half){
fee/=2;
fee+=25;
fee/=50;
fee*=50;
}
cout<<fee<<endl;
}
} |
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm> // require sort next_permutation count etc.
#include <cstdlib> // require abs
#include <cstdio> // require printf
#include <functional>
#include <numeric> // require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip> // require setw
#include <sstream> // require stringstream
#include <cstring> // require memset
#include <cctype> // require tolower, toupper
#include <fstream> // require freopen
#include <stdint.h> // require uint64_t
using namespace std;
int main()
{
int price[][7] = {
{ 0, 300, 500, 600, 700,1350,1650 },
{ 0, 0, 350, 450, 600,1150,1500 },
{ 0, 0, 0, 250, 400,1000,1350 },
{ 0, 0, 0, 0, 250, 850,1300 },
{ 0, 0, 0, 0, 0, 600,1150 },
{ 0, 0, 0, 0, 0, 0, 500 },
{ 0, 0, 0, 0, 0, 0, 0 } };
int dist[][7] = {
{ 0, 0, 0, 0, 0, 0, 0 },
{ 6, 0, 0, 0, 0, 0, 0 },
{ 13, 7, 0, 0, 0, 0, 0 },
{ 18, 12, 5, 0, 0, 0, 0 },
{ 23, 17, 10, 5, 0, 0, 0 },
{ 43, 37, 30, 25, 20, 0, 0 },
{ 58, 52, 45, 40, 35, 15, 0 } };
for (int i = 0; i < 7; ++i ){
for (int j = 0; j < 7; ++j ){
if (i != j ){
if (price[i][j] == 0 ){
price[i][j] = price[j][i];
} // end if
if (dist[i][j] == 0 ){
dist[i][j] = dist[j][i];
} // end if
} // end if
} // en for
} // end for
// cut here before submit
// freopen ("testcase.highwaytoll", "r", stdin );
int from;
while (cin >> from && from ){
int fromh, fromm;
cin >> fromh >> fromm;
int to,toh, tom;
cin >> to >> toh >> tom;
from--;to--;
int res = 0;
int em = fromh*60 + fromm;
int dm = toh*60 + tom;
// ツ環暗クツ妥篠湘崢づ個篠楪甘板妥堕づづ債づ按つ「
// if (em < 17*60 + 30 && dm > 19*60 + 30 ){
if ( (17*60 + 30 <= em && em <= 19*60 + 30 )
|| (17*60 + 30 <= dm && dm <= 19*60 + 30 ) ){
int d = dist[from][to];
if (d > 40 ){
res = price[from][to];
}else{
res = (price[from][to]/2 + 49)/50*50;
} // end if
}else{
res = price[from][to];
} // end if
cout << res << endl;
} // end loop
return 0;
} |
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
static const double eps = 10e-8;
struct IC{
int fare;
int dist;
};
int main(){
int dpt,arv;
struct IC ic[] = {
300,6,
500,13,
600,18,
700,23,
1350,43,
1650,58,
350,7,
450,12,
600,17,
1150,37,
1500,52,
250,5,
400,10,
1000,30,
1350,45,
250,5,
850,25,
1300,40,
600,20,
1150,35,
500,15,
};
while(~scanf("%d",&dpt)){
if(dpt==0) break;
int hDpt,mDpt;
scanf("%d %d",&hDpt,&mDpt);
scanf("%d",&arv);
int hArv,mArv;
scanf("%d %d",&hArv,&mArv);
int DptT = hDpt*60+mDpt;
int ArvT = hArv*60+mArv;
int idx=0;
int fare=0,dist=0;
for(int i=1;i<=7;i++){
for(int j=i+1;j<=7;j++){
if(i==dpt && j==arv){
fare = ic[idx].fare;
dist = ic[idx].dist;
goto found;
}
idx++;
}
}
found:;
if(((17*60+30 <= DptT && DptT <= 19*60+30)
|| (17*60+30 <= ArvT && ArvT <= 19*60+30))
&& dist <= 40){
fare /=2;
}
int tmp = fare / 50;
if(fare % 50) fare = 50 * (tmp+1);
printf("%d\n",fare);
}
} |
#include <iostream>
using namespace std;
int m(int h, int m) {
return h*60+m;
}
int main() {
int base[8][8] = {{0,0,0,0,0,0,0,0},
{0,0, 300,500,600,700,1350,1650},
{0,6, 0, 350,450,600,1150,1500},
{0,13,7, 0, 250,400,1000,1350},
{0,18,12, 5, 0, 250,850, 1300},
{0,23,17, 10, 5, 0, 600, 1150},
{0,43,37, 30, 25, 20, 0, 500},
{0,58,52, 45, 40, 35, 15, 0}};
while(1) {
int s,g;
int sh, sm, gh, gm;
cin >> s;
if(s == 0) break;
cin >> sh >> sm;
cin >> g;
cin >> gh >> gm;
int temp;
if(s > g) {
temp = s;
s = g;
g = temp;
}
bool half = false;
if(m(sh,sm) >= m(17,30) && m(sh,sm) <= m(19,30) && base[g][s] <= 40) {
half = true;
}
else if(m(gh,gm) >= m(17,30) && m(gh,gm) <= m(19,30) && base[g][s] <= 40) {
half = true;
}
if(half) {
temp = (base[s][g] / 2 + 49) / 50 * 50;
cout << temp << endl;
} else {
cout << base[s][g] << endl;
}
}
return 0;
} |
#include <iostream>
using namespace std;
int p[7][7] = {
{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}
};
int d[7][7] = {
{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}
};
int main () {
int a, b;
while (cin >> a, a) {
int h, m;
bool half = false;
cin >> h >> m;
int s = h * 60 + m;
if (17 * 60 + 30 <= s && s <= 19 * 60 + 30) half = true;
cin >> b;
cin >> h >> m;
s = h * 60 + m;
if (17 * 60 + 30 <= s && s <= 19 * 60 + 30) half = true;
a--, b--;
int price = p[a][b];
int dist = d[a][b];
if (dist <= 40 && half) price /= 2;
cout << price + (price % 50) << endl;
}
return 0;
} |
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
int money[7][7] = {{},{300},{500,350},{600,450,250},{700,600,400,250},{1350,1150,1000,850,600},{1650,1500,1350,1300,1150,500}};
int dis[7][7] = {{},{6},{13,7},{18,12,5},{23,17,10,5},{43,37,30,25,20},{58,52,45,40,35,15}};
int sn,sh,sm,gn,gh,gm;
while(cin >> sn && sn)
{
cin >> sh >> sm >> gn >> gh >> gm;
sn--;
gn--;
int s = sh*100 + sm;
int e = gh*100 + gm;
if(s < 1730 && 1930 < e)
{
cout << money[gn][sn] << endl;
}
else
{
int m = money[gn][sn];
if(dis[gn][sn] <= 40)
{
if(m % 100 == 0)
{
cout << m/2 << endl;
}
else
{
cout << (m+50)/2 << endl;
}
}
else
{
cout << m << endl;
}
}
}
return 0;
} |
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int c[7][7] ={
{0, 300, 500, 600, 700, 1350, 1650},
{0, 0, 350, 450, 600, 1150, 1500},
{0, 0, 0, 250, 400, 1000, 1350},
{0, 0, 0, 0, 250, 850, 1300},
{0, 0, 0, 0, 0, 600, 1150},
{0, 0, 0, 0, 0, 0, 500}};
int d[6] = {6,7,5,5,20,15};
int main(){
int s, t, h1, m1, h2, m2;
while(cin >> s, s) {
cin >> h1 >> m1 >> t >> h2 >> m2;
s--, t--;
if(s>t) swap(s,t);
int dist = 0;
rep(i,7) {
if(s<=i&&i<t) dist += d[i];
}
if(h1*60+m1>=17*60+30 && 19*60+30>=h1*60+m1 ||
h2*60+m2>=17*60+30 && 19*60+30>=h2*60+m2) {
if(dist <= 40) cout << ceil(c[s][t] / 100.0) * 50 << endl;
else cout << c[s][t] << endl;
} else cout << c[s][t] << endl;
}
return 0;
} |
#include<iostream>
#include<cstdlib>
using namespace std;
int charge(int in, int out);
int dist(int in, int out);
int checkhalf(int ih, int im, int oh, int om, int dis);
int half(int y);
int main(){
int inic, inh, inm, outic, outh, outm, yen, kyori;
while(1){
cin >>inic;
if(inic == 0) break;
cin >>inh >>inm >>outic >>outh >>outm;
yen = charge(inic, outic);
kyori = dist(inic, outic);
if(checkhalf(inh, inm, outh, outm, kyori)) yen = half(yen);
cout <<yen <<endl;
}
return 0;
}
int charge(int in, int out){
if(in == 1){
if(out == 2) return 300;
if(out == 3) return 500;
if(out == 4) return 600;
if(out == 5) return 700;
if(out == 6) return 1350;
if(out == 7) return 1650;
} else if(in == 2){
if(out == 1) return 300;
if(out == 3) return 350;
if(out == 4) return 450;
if(out == 5) return 600;
if(out == 6) return 1150;
if(out == 7) return 1500;
} else if(in == 3){
if(out == 1) return 500;
if(out == 2) return 350;
if(out == 4) return 250;
if(out == 5) return 400;
if(out == 6) return 1000;
if(out == 7) return 1350;
} else if(in == 4){
if(out == 1) return 600;
if(out == 2) return 450;
if(out == 3) return 250;
if(out == 5) return 250;
if(out == 6) return 850;
if(out == 7) return 1300;
} else if(in == 5){
if(out == 1) return 700;
if(out == 2) return 600;
if(out == 3) return 400;
if(out == 4) return 250;
if(out == 6) return 600;
if(out == 7) return 1150;
} else if(in == 6){
if(out == 1) return 1350;
if(out == 2) return 1150;
if(out == 3) return 1000;
if(out == 4) return 850;
if(out == 5) return 600;
if(out == 7) return 500;
} else if(in == 7){
if(out == 1) return 1650;
if(out == 2) return 1500;
if(out == 3) return 1350;
if(out == 4) return 1300;
if(out == 5) return 1150;
if(out == 6) return 500;
}
}
int dist(int in, int out){
if(in == 1){
if(out == 2) return 6;
if(out == 3) return 13;
if(out == 4) return 18;
if(out == 5) return 23;
if(out == 6) return 43;
if(out == 7) return 58;
} else if(in == 2){
if(out == 1) return 6;
if(out == 3) return 7;
if(out == 4) return 12;
if(out == 5) return 17;
if(out == 6) return 37;
if(out == 7) return 52;
} else if(in == 3){
if(out == 1) return 13;
if(out == 2) return 7;
if(out == 4) return 5;
if(out == 5) return 10;
if(out == 6) return 30;
if(out == 7) return 45;
} else if(in == 4){
if(out == 1) return 18;
if(out == 2) return 12;
if(out == 3) return 5;
if(out == 5) return 5;
if(out == 6) return 25;
if(out == 7) return 40;
} else if(in == 5){
if(out == 1) return 23;
if(out == 2) return 17;
if(out == 3) return 10;
if(out == 4) return 5;
if(out == 6) return 20;
if(out == 7) return 35;
} else if(in == 6){
if(out == 1) return 43;
if(out == 2) return 37;
if(out == 3) return 30;
if(out == 4) return 25;
if(out == 5) return 20;
if(out == 7) return 15;
} else if(in == 7){
if(out == 1) return 58;
if(out == 2) return 52;
if(out == 3) return 45;
if(out == 4) return 40;
if(out == 5) return 35;
if(out == 6) return 15;
}
}
int checkhalf(int ih, int im, int oh, int om, int dis){
int flag1 = 0, flag2 = 0;
int in = (ih * 60) + im, out = (oh * 60) + om;
if(dis > 40) return 0;
if(in >= (17 * 60 + 30) && in <= (19 * 60 + 30)){
flag1 = 1;
}
if(out >= (17 * 60 + 30) && out <= (19 * 60 + 30)){
flag2 = 1;
}
if(flag1 || flag2){
return 1;
} else{
return 0;
}
}
int half(int y){
int temp = y;
temp /= 2;
if(temp % 50 != 0){
temp = temp + abs((temp % 50) - 50);
}
return temp;
} |
#include <map>
#include <cstdio>
int main(){std::map<int,int>z={{12,6},{13,10},{14,12},{15,14},{16,27},{17,33},{23,7},{24,9},{25,12},{26,23},{27,30},{34,5},{35,8},{36,20},{37,27},{45,5},{46,17},{47,26},{56,12},{57,23},{67,10}};for(int a,b,h,m,H,M;scanf("%d%d%d%d%d%d",&a,&h,&m,&b,&H,&M)>5;printf("%d\n",(h+H)*50))if(m+=h*60,M+=H*60,h=z[a*10+b],H=0,h<27&&((1050<=m&&m<=1170)||(1050<=M&&M<=1170)))H=(h&1),h/=2;} |
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>
#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <bitset>
using namespace std;
#ifdef _MSC_VER
#define __typeof__ decltype
#define strtok_r strtok_s
#endif
#define ITER(c) __typeof__((c).begin())
#define FOREACH(it, c) for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c) __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n) REPEAT(i, 0, n)
#define RREP(i, n) RREPEAT(i, 0, n)
#define REPEAT(i, k, n) for(int i = (k); i < ((k)+(n)); ++i)
#define RREPEAT(i, k, n) for(int i = (k)+(n)-1; i >= (k); --i)
#define FROMTO(i,f,t) for(int i = f; i < t; i++)
#define ALL(c) (c).begin(), (c).end()
#define LLPOW(p1,p2) ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A) (sizeof(A)/sizeof((A)[0]))
#define CIN_NO_SYNC do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p) fgets((p), sizeof(p), stdin)
#define CHOMP(p) do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)
#define FILL(m,v) memset(m, v, sizeof(m))
#define mp make_pair
#define pb push_back
template<class _T> _T MAX(_T p1,_T p2){return (p1>p2)?p1:p2;}
template<class _T> _T MIN(_T p1,_T p2){return (p1<p2)?p1:p2;}
template <class _Tv> inline string join(const _Tv &v,string sep=" "){
ostringstream s;FOREACH(it,v){if(it!=v.begin())s<<sep;s<<*it;};return s.str();
}
typedef long long ll;
typedef unsigned long long ull;
typedef double D;
typedef complex<D> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define X real()
#define Y imag()
#define EPS (1e-9)
#define DEQ(p1,p2) (abs((p1)-(p2)) < EPS)
#ifdef _DEBUG
template<class _Tv> inline void _prfe(const char *_n,const _Tv _c,bool _p=false){
ITER(_c) _it=_c.begin();
if(_p){cout<<_n<<" = ["<<endl;for(;_it!=_c.end();++_it)cout<<" "<<*_it<<endl;cout<<"]"<<endl; }
else{cout<<_n<<" = [ "<<*_it++;for(;_it!=_c.end();++_it)cout<<", "<<*_it;cout<<" ]"<<endl; }
}
ostream &operator<<(ostream &os, const pair<int,int> &p){return(os<<"("<<p.first<<","<<p.second<<")");}
#define pf printf
#define pr(n) do{cout<<#n" = "<<(n)<<endl;}while(0)
#define prfe(n) _prfe(#n, n)
#define prfep(n) _prfe(#n, n, true)
#define dbgchk(n) do{if(n)throw;}while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#define prfe(...) /* */
#define prfep(...) /* */
#define dbgchk(...) /* */
#endif
int tbl[][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},
};
inline int ceil50(int n){ return (n+50-1)/50*50; }
int solve(int s, int t1, int g, int t2){
int cost = tbl[MIN(s,g)-1][MAX(s,g)-1];
int leng = tbl[MAX(s,g)-1][MIN(s,g)-1];
if( ((17*60+30 <= t1 && t1 <= 19*60+30) || (17*60+30 <= t2 && t2 <= 19*60+30)) && leng <= 40){
cost = ceil50(cost/2);
}
return cost;
}
int main(){
int s, g;
while(cin >> s && s){
int h1,m1,h2,m2;
cin >> h1 >> m1 >> g >> h2 >> m2;
cout << solve(s,h1*60+m1,g,h2*60+m2) << endl;
}
return 0;
} |
#include<stdio.h>
int d[7][7]={{0,6,10,12,14,27,33},{6,0,7,9,12,23,30},{10,7,0,5,8,20,27},{12,9,5,0,5,17,26},{14,12,8,5,0,12,23},{27,23,20,17,12,0,10},{33,30,27,26,23,10,0}};
int c[]={0,6,13,18,23,43,58};
int ABS(int a){return a<0?-a:a;}
int main(){
int a;
while(scanf("%d",&a),a){
a--;
int p,q,r,s,t;
scanf("%d%d%d%d%d",&p,&q,&r,&s,&t);
r--;
int ret=d[a][r];
if(ABS(c[a]-c[r])<=40){
if(1050<=p*60+q&&p*60+q<=1170)ret=(ret+1)/2;
else if(1050<=s*60+t&&s*60+t<=1170)ret=(ret+1)/2;
}printf("%d\n",ret*50);
}
} |
#include<iostream>
int toMinute(int h, int m){
return h * 60 + m;
}
int roundUp(int i){
if(i % 50){
return i - (i % 50) + 50;
}
return i;
}
//17*60+30 = 1050
//19*60+30 = 1170
int main(){
int MAX_N = 7;
int d[MAX_N+1][MAX_N+1], p[MAX_N+1][MAX_N+1];
d[1][2] = 6;
d[1][3] = 13;
d[1][4] = 18;
d[1][5] = 23;
d[1][6] = 43;
d[1][7] = 58;
d[2][3] = 7;
d[2][4] = 12;
d[2][5] = 17;
d[2][6] = 37;
d[2][7] = 52;
d[3][4] = 5;
d[3][5] = 10;
d[3][6] = 30;
d[3][7] = 45;
d[4][5] = 5;
d[4][6] = 25;
d[4][7] = 40;
d[5][6] = 20;
d[5][7] = 35;
d[6][7] = 15;
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;
int a, na, ma;
while(std::cin >> a >> na >> ma, !std::cin.eof()){
int b, nb, mb;
std::cin >> b >> nb >> mb;
int min_a = toMinute(na, ma),
min_b = toMinute(nb, mb);
int big = (a>b)?a:b,
small = (a<b)?a:b;
if((1050 <= min_a && min_a <= 1170 ||
1050 <= min_b && min_b <= 1170) &&
d[small][big] <= 40){
std::cout << roundUp(p[small][big] / 2) << std::endl;
}else{
std::cout << p[small][big] << std::endl;
}
}
} |
#include<iostream>
using namespace std;
int cost[8][8] = {{},{0,0,300,500,600,700,1350,1650},
{0,0,0,350,450,600,1150,1500},
{0,0,0,0,250,400,1000,1350},
{0,0,0,0,0,250,850,1300},
{0,0,0,0,0,0,600,1150},
{0,0,0,0,0,0,0,500}};
int dis[8][8] = {{},{0,0,6,13,18,23,43,58},
{0,0,0,7,12,17,37,52},
{0,0,0,0,5,10,30,45},
{0,0,0,0,0,5,25,40},
{0,0,0,0,0,0,20,35},
{0,0,0,0,0,0,0,15}};
struct T{int ic,h,m;};
T t[2];
bool check(T in){
if(17 < in.h && in.h < 19) return true;
if(in.h == 17 && in.m >= 30) return true;
if(in.h == 19 && in.m <= 30) return true;
return false;
}
int solve(T from, T to){
int ans = 0;
bool half = (check(from)||check(to));
int fi = from.ic,ti = to.ic;
if(from.ic > to.ic) swap(fi,ti);
ans = cost[fi][ti];
if(half && dis[fi][ti] <= 40) ans /= 2;
while((ans%100)%50) ans++;
return ans;
}
int main(){
while(cin >> t[0].ic && t[0].ic){
cin >> t[0].h >> t[0].m;
cin >> t[1].ic >> t[1].h >> t[1].m;
cout << solve(t[0],t[1]) << endl;
}
return 0;
} |
#include<iostream>
using namespace std;
//料金2次元配列
const int wh_data[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}};
//時間入力構造体
typedef struct struct_time_input
{
int number;
int h;
int m;
}S_time_input;
//半額時間
typedef struct struct_price
{
int price_start;
int price_end;
}S_price;
int main(void)
{
//安い時間を宣言
const S_price s_price = {60 * 17 + 30 , 60 * 19 + 30};
while (true)
{
//入力変数
S_time_input s_start = {0};
S_time_input s_end = {0};
//金
int money = 0;
//距離
int length = 0;
cin >> s_start.number;
if (s_start.number == 0) { return 0; };
cin >> s_start.h >> s_start.m;
cin >> s_end.number >> s_end.h >> s_end.m;
money = wh_data[s_start.number - 1][s_end.number - 1];
length = wh_data[s_end.number - 1][s_start.number - 1];
//まず距離が40km以内
if (length <= 40)
{
//それぞれの時間を計測
int start_time = s_start.h * 60 + s_start.m;
int end_time = s_end.h * 60 + s_end.m;
//まずは範囲内
if (start_time <= s_price.price_end && end_time >= s_price.price_start)
{
//両方範囲から外れているのならOUT
if (start_time < s_price.price_start && end_time > s_price.price_end)
{
;
}
else
{
money /= 2;
if (money % 50 != 0)
{
int sa = 0;
sa = money % 50;
money -= sa;
money += 50;
}
}
}
}
cout << money << endl;
}
return 0;
} |
#include <bits/stdc++.h>
using namespace std;
const int Distance[8][8] = {
{ 0, 00, 00, 00, 00, 00, 00, 00 },
{ 0, 00, 06, 13, 18, 23, 43, 58 },
{ 0, 06, 00, 07, 12, 17, 37, 52 },
{ 0, 13, 07, 00, 05, 10, 30, 45 },
{ 0, 18, 23, 43, 00, 05, 25, 40 },
{ 0, 23, 17, 10, 05, 00, 20, 35 },
{ 0, 43, 37, 30, 25, 20, 00, 15 },
{ 0, 58, 52, 45, 40, 35, 15, 00 },
};
const int Money[8][8] = {
{ 0, 000, 000, 000, 000, 000, 0000, 0000 },
{ 0, 000, 300, 500, 600, 700, 1350, 1650 },
{ 0, 300, 000, 350, 450, 600, 1150, 1500 },
{ 0, 500, 350, 000, 250, 400, 1000, 1350 },
{ 0, 600, 450, 250, 000, 250, 850, 1300 },
{ 0, 700, 600, 400, 250, 000, 600, 1150 },
{ 0, 1350, 1150, 1000, 850, 600, 000, 500 },
{ 0, 1650, 1500, 1350, 1300, 1150, 500, 000 },
};
const int TimeMin = 17 * 60 + 30;
const int TimeMax = 19 * 60 + 30;
int main() {
int d, a, hd, md, ha, ma, timeD, timeA, sum;
while (cin >> d, d) {
cin >> hd >> md;
cin >> a >> ha >> ma;
sum = Money[d][a];
timeD = hd * 60 + md;
timeA = ha * 60 + ma;
if ( Distance[d][a] <= 40 && (timeD>=TimeMin && timeD<=TimeMax || timeA>=TimeMin && timeA<=TimeMax) ) {
sum /= 2;
if (sum % 50 != 0) {
sum += 50 - sum % 50;
}
}
cout << sum << endl;
}
return 0;
}
|
#include<bits/stdc++.h>
using namespace std;
int main()
{
int distance[]={6,7,5,5,20,15},money[6][6]={{300,500,600,700,1350,1650},{350,450,600,1150,1500},{250,400,1000,1350},{250,850,1300},{600,1150},{500}};
int time[2][3];
while(cin>>time[0][0],time[0][0]){
for(int i=1;i<3;i++)cin>>time[0][i];
for(int i=0;i<3;i++)cin>>time[1][i];
int num=0;
for(int i=time[0][0];i<time[1][0];i++)num+=distance[i-1];
bool kawa=0;
for(int i=0;i<2&&!kawa&&num<41;i++)if(time[i][1]==18||time[i][1]==17&&time[i][2]>29||time[i][1]==19&&time[i][2]<31)kawa=1;
num=money[time[0][0]-1][time[1][0]-time[0][0]-1];
if(kawa){
num/=2;
if(num%50!=0)num+=25;
}
cout<<num<<endl;
}
} |
#include <bits/stdc++.h>
using namespace std;
int tb[8][8] =
{
{0,0,0,0,0,0,0,0},
{0,0,300,500,600,700,1350,1650},
{0,6,0,350,450,600,1150,1500},
{0,13,7,0,250,400,1000,1350},
{0,18,12,5,0,250,850,1300},
{0,23,17,10,5,0,600,1150},
{0,43,37,30,25,20,0,500},
{0,58,52,45,40,35,15,0}
};
int d,hd,md,a,ha,ma;
int to_m(int h,int m){
return h * 60 + m;
}
bool time_ok(){
int dt = to_m(hd,md);
int at = to_m(ha,ma);
int t1730 = to_m(17,30);
int t1930 = to_m(19,30);
return (dt >= t1730 && dt <= t1930) || (at >= t1730 && at <= t1930);
}
bool is_half(){
return tb[a][d] <= 40 && time_ok();
}
int roundup(int f){
int h = f % 50;
if(h > 0){
return f - h + 50;
}
else{
return f;
}
}
int fee(){
return is_half() ? roundup(tb[d][a] / 2) : roundup(tb[d][a]);
}
int main(){
while(cin >> d, d != 0){
cin >> hd >> md >> a >> ha >> ma;
cout << fee() << endl;
}
return 0;
}
|
#include<iostream>
#include<algorithm>
using namespace std;
int a,b,c,d,e,f;
int u=17*60+30,v=19*60+30;
int t[8][8]={
{0,0,0,0,0,0,0,0},
{0, 0, 300, 500, 600, 700,1350,1650},
{0, 6, 0, 350, 450, 600,1150,1500},
{0,13, 7, 0, 250, 400,1000,1350},
{0,18, 12, 5, 0, 250, 850,1300},
{0,23, 17, 10, 5, 0, 600,1150},
{0,43, 37, 30, 25, 20, 0, 500},
{0,58, 52, 45, 40, 35, 15, 0}
};
bool check(){
if(t[max(a,d)][min(a,d)]>40)return false;
int x=b*60+c,y=e*60+f;
if((x<u||v<x)&&(y<u||v<y)){
return false;
}
return true;
}
int change(int x){
if(x%100==50){
x-=50;
return x/2+50;
}else{
return x/2;
}
}
int main(){
while(cin>>a&&a){
cin>>b>>c>>d>>e>>f;
if(check()){
cout<<change(t[min(a,d)][max(a,d)])<<endl;
}else{
cout<<t[min(a,d)][max(a,d)]<<endl;
}
}
return 0;
} |
#include <iostream>
#include <algorithm>
using namespace std;
int table[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 sic;
while (cin >> sic) {
if (sic == 0)
break;
int sh, sm, tic, th, tm;
cin >> sh >> sm >> tic >> th >> tm;
--sic;
--tic;
bool half = false;
if (((17*60+30 <= sh*60+sm && sh*60+sm <= 19*60+30) ||
(17*60+30 <= th*60+tm && th*60+tm <= 19*60+30)) &&
table[max(sic, tic)][min(sic, tic)] <= 40)
half = true;
int ans = table[min(sic, tic)][max(sic, tic)];
if (half) {
ans /= 2;
if (ans % 50 != 0)
ans = ((ans+49) / 50) * 50;
}
cout << ans << endl;
}
return 0;
} |
//07
#include<iostream>
#include<algorithm>
#define T(h,m) ((h)*60+(m))
using namespace std;
int main(){
for(int s;cin>>s,s;){
int sh,sm;
int t,th,tm;
cin>>sh>>sm>>t>>th>>tm;
s--;
t--;
int f[7][7]={{0,300,500,600,700,1350,1650},{0,0,350,450,600,1150,1500},{0,0,0,250,400,1000,1350},{0,0,0,0,250,850,1300},{0,0,0,0,0,600,1150},{0,0,0,0,0,0,500},{0,0,0,0,0,0,0}};
int d[7][7]={{0,0,0,0,0,0,0},{6,0,0,0,0,0,0},{13,7,0,0,0,0,0},{18,12,5,0,0,0,0},{23,17,10,5,0,0,0},{43,37,30,25,20,0,0},{58,52,45,40,35,15}};
int sum=max(f[s][t],f[t][s]);
if(!((T(sh,sm)<T(17,30)&&T(19,30)<T(th,tm))||T(sh,sm)>T(19,30)||T(th,tm)<T(17,30))&&max(d[s][t],d[t][s])<=40){
sum=sum/2+((sum%100==50)?25:0);
}
cout<<sum<<endl;
}
return 0;
} |
#include <iostream>
using namespace std;
const int c[][8] = {
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 300, 500, 600, 700, 1350, 1650},
{0, 6, 0, 350, 450, 600, 1150, 1500},
{0, 13, 7, 0, 250, 400, 1000, 1350},
{0, 18, 12, 5, 0, 250, 850, 1300},
{0, 23, 17, 10, 5, 0, 600, 1150},
{0, 43, 37, 30, 25, 20, 0, 500},
{0, 58, 52, 45, 40, 35, 15, 0},
};
const int bt = 60 * 17 + 30;
const int lt = 60 * 19 + 30;
int main() {
int s;
while (cin >> s, s) {
bool half = false;
int hh, mm;
cin >> hh >> mm;
int time = 60 * hh + mm;
half |= (bt <= time && time <= lt);
int t;
cin >> t >> hh >> mm;
time = 60 * hh + mm;
half |= (bt <= time && time <= lt);
half &= (c[t][s] <= 40);
int ans = c[s][t];
if (half) {
ans /= 2;
if (ans % 50 != 0) {
ans += 50 - (ans % 50);
}
}
cout << ans << endl;
}
} |
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;
vector<vector<int>>money{
{0,300,500,600,700,1350,1650},
{0,0,350,450,600,1150,1500},
{0,0,0,250,400,1000,1350},
{0,0,0,0,250,850,1300},
{0,0,0,0,0,600,1150},
{0,0,0,0,0,0,500},
{ 0,0,0,0,0,0,0 },
};
vector<int>dis{ 6,7,5,5,20,15 };
int main() {
while (1) {
int d; cin >> d;
if (!d)break;
int start,goal;
{
int h, m; cin >> h >> m;
start = h * 60 + m;
}
int a; cin >> a;
{
int h, m; cin >> h >> m;
goal = h * 60 + m;
}
d--; a--;
if (d < a)swap(d, a);
int cost = money[a][d];
cost /= 50;
int distance = 0;
for (int i = a; i < d; ++i) {
distance += dis[i];
}
bool flag = false;
if ((start <= 1170 || 1050 <= goal)&&!(start<1050&&1170<goal))flag = true;
if (distance <= 40 && flag)cost = (cost + 1) / 2;
cost *= 50;
cout << cost << endl;
}
return 0;
} |
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
#include<climits>
using namespace std;
int cost[7][7] = {
{ 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}
};
int dist[7][7] = {
{ 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}
};
int ToMinute(int h, int m){
return h*60 + m;
}
bool IsInTime(int h, int m){
return ToMinute(17, 30) <= ToMinute(h, m) && ToMinute(h, m) <= ToMinute(19, 30);
}
int ToHalf(int n){
n /= 2;
if(n%50) n += 50 - n%50;
return n;
}
int main(){
int ic1, ic2, h1, h2, m1, m2;
while(cin >> ic1, ic1){
cin >> h1 >> m1 >> ic2 >> h2 >> m2;
ic1--; ic2--;
bool is_half = ( IsInTime(h1, m1) || IsInTime(h2, m2) ) && dist[ic1][ic2] <= 40;
if(is_half) printf("%d\n", ToHalf(cost[ic1][ic2]) );
else printf("%d\n", cost[ic1][ic2]);
}
return 0;
} |
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
bool in(int h, int m){
if((h == 17 && m >=30)||(h == 18)||(h == 19 && m <=30)) return true;
return false;
}
signed main(){
int s, t, sh, sm, th, tm;
int d[49] = {0, 30, 50, 60, 70, 135, 165,
6, 0, 35, 45, 60, 115, 150,
13, 7, 0, 25, 40, 100, 135,
18, 12, 5, 0, 25, 85, 130,
23, 17, 10, 5, 0, 60, 115,
43, 37, 30, 25, 20, 0, 50,
58, 52, 45, 40, 35, 15, 0};
while(cin >> s, s){
cin >> sh >> sm >> t >> th >> tm;
s--; t--;
if(s > t) swap(s, t);
int ans = d[s*7 + t] * 10;
if((in(sh, sm)||in(th, tm)) && d[t*7 + s] <= 40) ans /= 2;
if(ans % 50 != 0) ans = (ans / 50 + 1)*50;
cout << ans << endl;
}
} |
#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(half[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;
} |
#include<iostream>
using namespace std;
int cost[8][8] =
{
{},
{0,0,300,500,600,700,1350,1650},
{0,6,0,350,450,600,1150,1500},
{0,13,7,0,250,400,1000,1350},
{0,18,12,5,0,250,850,1300},
{0,23,17,10,5,0,600,1150},
{0,43,37,30,25,20,0,500},
{0,58,52,45,40,35,15,0}
};
int l,lh,lm,a,ah,am;
int main(){
while(true){
cin >> l;
if(!l)
return 0;
cin >> lh >> lm;
lm+=lh*100;
cin >> a;
cin >> ah >> am;
am+=ah*100;
if(cost[max(l,a)][min(l,a)] > 40)
cout << cost[min(l,a)][max(l,a)] << endl;
else if((lm>=1730&&lm<=1930)||(am>=1730&&am<=1930)){
bool flag = false;
if((cost[min(l,a)][max(l,a)]/2)%50)
flag = true;
int ans = cost[min(l,a)][max(l,a)]/2-((cost[min(l,a)][max(l,a)]/2)%50);
if(flag)
ans+=50;
cout << ans << endl;
}else
cout << cost[min(l,a)][max(l,a)] << endl;
}
} |
#include <iostream>
using namespace std;
int price[8][8]={
{0,0,0,0,0,0,0,0},
{0,0,300,500,600,700,1350,1650},
{0,300,0,350,450,600,1150,1500},
{0,500,350,0,250,400,1000,1350},
{0,600,450,250,0,250,850,1300},
{0,700,600,400,250,0,600,1150},
{0,1350,1150,1000,850,600,0,500},
{0,1650,1500,1350,1300,1150,500,0}
};
int dist[8][8]={
{0,0,0,0,0,0,0,0},
{0,0,6,13,18,23,43,58},
{0,6,0,7,12,17,37,52},
{0,13,7,0,5,10,30,45},
{0,18,12,5,0,5,25,40},
{0,23,17,10,5,0,20,35},
{0,43,37,30,25,20,0,15},
{0,58,52,45,40,35,15,0}
};
int calSec(int h,int m){
return h * 60 + m;
}
int main(void){
int ts=calSec(17,30),te=calSec(19,30);
int s,g,st,gt;
while(cin>>s && s){
int h,m;
cin>>h>>m;
st = calSec(h,m);
cin>>g>>h>>m;
gt = calSec(h,m);
bool flg = false;
if(dist[s][g]<=40 && (ts<=st && st<=te || ts<=gt && gt<=te)) flg = true;
int ans = price[s][g];
if(flg){
ans /= 2;
int rem = ans % 50;
if(rem != 0) ans += 50 - rem;
}
cout<<ans<<endl;
}
return 0;
} |
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
char c1[2],c2[2];
int h,m,ic[2],f[2],i,k;
int g[7][7]={{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}};
while(true) {
for (i=0;i<2;i++) {
cin >> ic[i];
if (ic[i]==0) return 0;
ic[i]--;
cin >> c1 >> c2;
h=(c1[0]-'0')*10+(c1[1]-'0');
m=(c2[0]-'0')*10+(c2[1]-'0');
f[i]=(h==17 && m>29) || (h==18) || (h==19 && m<31);
}
k=g[ic[0]][ic[1]];
if(k<1350)
if (f[0]+f[1]>0) k=k % 100>0 ? k/2+25:k/2;
cout << k << endl;
}
return 0;
} |
#include<bits/stdc++.h>
using namespace std;
int main(){
int a[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 b;
while(cin>>b,b){
int c,d,e,f,g;
scanf("%d%d%d%d%d",&c,&d,&e,&f,&g);
c=c*60+d;
f=f*60+g;
if(c>=1050&&c<=1170||f>=1050&&f<=1170){
if(a[max(b,e)-1][min(b,e)-1]<=40){int o=a[min(b,e)-1][max(b,e)-1]/2;if(o%50)o+=50-o%50;printf("%d\n",o);}
else printf("%d\n",a[min(b,e)-1][max(b,e)-1]);
}
else printf("%d\n",a[min(b,e)-1][max(b,e)-1]);
}
} |
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
using namespace std;
int main(){
int start,goal,start_h,start_m,goal_h,goal_m,ans;
int dist[8] = {0,0,6,13,18,23,43,58},toll[8][8];
toll[1][1] = 0,toll[1][2] = 300,toll[1][3] = 500,toll[1][4] = 600,toll[1][5] = 700,toll[1][6] = 1350,toll[1][7] = 1650;
toll[2][2] = 0,toll[2][3] = 350,toll[2][4] = 450,toll[2][5] = 600,toll[2][6] = 1150,toll[2][7] = 1500;
toll[3][3] = 0,toll[3][4] = 250,toll[3][5] = 400,toll[3][6] = 1000,toll[3][7] = 1350;
toll[4][4] = 0,toll[4][5] = 250,toll[4][6] = 850,toll[4][7] = 1300;
toll[5][5] = 0,toll[5][6] = 600,toll[5][7] = 1150;
toll[6][6] = 0,toll[6][7] = 500;
while(true){
scanf("%d",&start);
if(start == 0)break;
scanf("%d %d",&start_h,&start_m);
scanf("%d",&goal);
scanf("%d %d",&goal_h,&goal_m);
ans = toll[start][goal];
if(dist[goal]-dist[start] <= 40){
if((start_h*60+start_m) >= 17*60+30 || (goal_h*60+goal_m) <= 19*60+30){
ans /= 2;
if(ans%50 > 0){
while(ans % 50 != 0)ans++;
}
}
}
printf("%d\n",ans);
}
return 0;
} |
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int s,sh,sm,g,gh,gm,ng[][2]={{0,5},{0,6},{1,6},{2,6}},t[][7]={{0,300,500,600,700,1350,1650},{0,0,350,450,600,1150,1500},{0,0,0,250,400,1000,1350},{0,0,0,0,250,850,1300},{0,0,0,0,0,600,1150},{0,0,0,0,0,0,500}};
int main(){
while(cin>>s&&s){
cin>>sh>>sm>>g>>gh>>gm;
s--;g--;
if(s>g)swap(s,g);
int st=sh*60+sm,gt=gh*60+gm;
int ok=1;
rep(i,4)if(s==ng[i][0]&&g==ng[i][1])ok=0;
if(ok&&(1050<=st&&st<=1170||1050<=gt&><=1170))cout<<(t[s][g]/50+1)/2*50<<endl;
else cout<<t[s][g]<<endl;
}
} |
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;
int main()
{
int table[][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 a = 17 * 60 + 30;
int b = 19 * 60 + 30;
for(;;){
int ic[2];
bool half = false;
for(int i=0; i<2; ++i){
int h, m;
cin >> ic[i] >> h >> m;
if(ic[i] == 0)
return 0;
-- ic[i];
m += h * 60;
if(a <= m && m <= b)
half = true;
}
if(ic[1] < ic[0])
swap(ic[0], ic[1]);
if(table[ic[1]][ic[0]] > 40)
half = false;
int ret = table[ic[0]][ic[1]];
if(half){
if(ret % 100 != 0)
ret += 50;
ret /= 2;
}
cout << ret << endl;
}
} |
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;
int toll[7][7] = {
{ 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}
};
int d[7][7] = {
{ 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}
};
int half(int x){
if((x / 2) % 50) x += 50;
return x / 2;
}
bool is_half(int h, int m, int d){
int t = h * 60 + m;
return ( 17*60 + 30 <= t && t <= 19*60 + 30 && d <= 40 );
}
int main(){
int s;
while( cin >> s, s ){
int h1, m1, h2, m2, g, ans;
cin >> h1 >> m1 >> g >> h2 >> m2;
s--; g--;
bool flag = ( is_half(h1,m1,d[s][g]) || is_half(h2,m2,d[s][g]) );
ans = flag? half(toll[s][g]) : toll[s][g] ;
cout << ans << endl;
}
} |
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int tolls[7][7] = {
{ -1, 300, 500, 600, 700, 1350, 1650},
{ 300, -1, 350, 450, 600, 1150, 1500},
{ 500, 350, -1, 250, 400, 1000, 1350},
{ 600, 450, 250, -1, 250, 850, 1300},
{ 700, 600, 400, 250, -1, 600, 1150},
{1350, 1150, 1000, 850, 600, -1, 500},
{1650, 1500, 1350, 1300, 1150, 500, -1}
};
int dist[7][7] = {
{-1, 6, 13, 18, 23, 43, 58},
{ 6, -1, 7, 12, 17, 37, 52},
{13, 7, -1, 5, 10, 30, 45},
{18, 12, 5, -1, 5, 25, 40},
{23, 17, 10, 5, -1, 20, 35},
{43, 37, 30, 25, 20, -1, 15},
{58, 52, 45, 40, 35, 15, -1}
};
int main() {
int ic1, h1, m1, ic2, h2, m2;
while (cin >> ic1, ic1) {
cin >> h1 >> m1 >> ic2 >> h2 >> m2;
--ic1; --ic2;
bool half = false;
int start = 17 * 60 + 30;
int end = 19 * 60 + 30;
int t1 = h1 * 60 + m1;
int t2 = h2 * 60 + m2;
if (dist[ic1][ic2] <= 40) {
if ((start <= t1 && t1 <= end) || (start <= t2 && t2 <= end)) {
half = true;
}
}
int res = tolls[ic1][ic2];
if (half) {
if (tolls[ic1][ic2] % 100 == 50) res += 50;
res /= 2;
}
cout << res << endl;
}
return 0;
} |
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(void){
int t[8][8];
int l[8][8];
t[1][2] = 300; t[1][3] = 500; t[1][4] = 600; t[1][5] = 700; t[1][6] = 1350; t[1][7] = 1650;
t[2][3] = 350; t[2][4] = 450; t[2][5] = 600; t[2][6] = 1150; t[2][7] = 1500;
t[3][4] = 250; t[3][5] = 400; t[3][6] = 1000; t[3][7] = 1350;
t[4][5] = 250; t[4][6] = 850; t[4][7] = 1300;
t[5][6] = 600; t[5][7] = 1150;
t[6][7] = 500;
l[1][2] = 6; l[1][3] = 13; l[1][4] = 18; l[1][5] = 23; l[1][6] = 43; l[1][7] = 58;
l[2][3] = 7; l[2][4] = 12; l[2][5] = 17; l[2][6] = 37; l[2][7] = 52;
l[3][4] = 5; l[3][5] = 10; l[3][6] = 30; l[3][7] = 45;
l[4][5] = 5; l[4][6] = 25; l[4][7] = 40;
l[5][6] = 20; l[5][7] = 35;
l[6][7] = 15;
int in,out,in_t,out_t,t1,t2;
while(cin >> in && in){
cin >> t1 >> t2;
in_t = t1*100+t2;
cin >> out;
cin >> t1 >> t2;
out_t = t1*100+t2;
if(in > out){
swap(in,out);
}
if(l[in][out] <= 40 && ((1730 <= in_t && in_t <= 1930) || (1730 <= out_t && out_t <= 1930))){
int tmp = std::ceil((double)(t[in][out] / 2) / 50);
cout << tmp * 50 << endl;
}else{
cout << t[in][out] << endl;
}
}
} |
#include<iostream>
using namespace std;
int main(){
int d[7][7] =
{{ -1,300,500,600,700,1350,1650}
,{ 6, -1,350,450,600,1150,1500}
,{ 13, 7, 0,250,400,1000,1350}
,{ 18, 12, 5, 0,250, 850,1300}
,{ 23, 17, 10, 5, -1, 600,1150}
,{ 43, 37, 30, 25, 20, -1, 500}
,{ 58, 52, 45, 40, 35, 15, -1}};
int s,t,hs,ms,ht,mt;
while(cin>>s,s){
cin>>hs>>ms>>t>>ht>>mt;
ms += hs*60;
mt += ht*60;
s--,t--;
bool flg = false;
if((17*60+30<=ms&&ms<=19*60+30)
||(17*60+30<=mt&&mt<=19*60+30))flg = true;
int price = d[s][t];
if(d[t][s] <= 40 && flg){
price/=2;
if(price%50!=0){
price += 50 - (price%50);
}
}
cout<<price<<endl;
}
return 0;
} |
#include<iostream>
using namespace std;
int main()
{
int dis_lst[]={0,0,6,13,18,23,43,58};
int prc_lst[7][8]={{},
{0,0,300,500,600,700,1350,1650},
{0,0, 0,350,450,600,1150,1500},
{0,0, 0, 0,250,400,1000,1350},
{0,0, 0, 0, 0,250, 850,1300},
{0,0, 0, 0, 0, 0, 600,1150},
{0,0, 0, 0, 0, 0, 0, 500},
};
for(int ic1,h1,m1,ic2,h2,m2;cin>>ic1>>h1>>m1>>ic2>>h2>>m2,ic1;){
if(ic1>ic2) swap(ic1,ic2);
int dis=dis_lst[ic2]-dis_lst[ic1];
bool harf=false;
if(dis<=40
&&((60*17+30<=60*h1+m1 && 60*h1+m1<=60*19+30)
|| (60*17+30<=60*h2+m2 && 60*h2+m2<=60*19+30))) harf=true;
int prc=prc_lst[ic1][ic2];
if(harf){
prc/=2;
if(prc%50>0) prc+=50-prc%50;
}
cout<<prc<<endl;
}
return 0;
} |
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
int aa[8][8]={ {0,1,2,3,4,5,6,7},
{1,0,300,500,600,700,1350,1650},
{2,300,0,350,450,600,1150,1500},
{3,500,350,0,250,400,1000,1350},
{4,600,450,250,0,250,850,1300},
{5,700,600,400,250,0,600,1150},
{6,1350,1150,1000,850,600,0,500},
{7,1650,1500,1350,1300,1150,500,0}};
int bb[8][8]={ {0,1,2,3,4,5,6,7},
{1,0,6,13,18,23,43,58},
{2,6,0,7,12,17,37,52},
{3,13,7,0,5,10,30,45},
{4,18,12,5,0,5,25,40},
{5,23,17,10,5,0,20,35},
{6,43,37,30,25,20,0,15},
{7,58,52,45,40,35,15,0}};
int i,j,n,time00,time01,time10,time11,n2,disc,mo;
int disc2;
while(1){
disc2=0;
disc=0; //flag
cin >> n;
if(n == 0)break;
cin >> time00 >> time01;
cin >> n2;
cin >> time10 >> time11;
if((time10 == 19 && time11 <= 30) || (time00 == 19 && time01 <=30)){disc2=1;}
else if(time00 == 18 || time10 == 18)disc2=1;
else if((time10 == 17 && time11>=30) || (time00 == 17 && time01 >=30))disc2=1;
if(bb[n2][n]<=40 && disc2==1)disc=1;
mo=aa[n][n2];
if(disc == 1){
mo=mo/2;
disc=0;
disc2=0;
if(mo%50 !=0)mo=(mo-(mo%50))+50;
}
cout << mo << endl;
}
return 0;
} |
#include<bits/stdc++.h>
using namespace std;
int main()
{
int distance[]={6,7,5,5,20,15},money[6][6]={{300,500,600,700,1350,1650},{350,450,600,1150,1500},{250,400,1000,1350},{250,850,1300},{600,1150},{500}};
int start,finish;
while(cin>>start,start){
int time[2][2];
for(int i=0;i<2;i++)cin>>time[0][i];
cin>>finish;
for(int i=0;i<2;i++)cin>>time[1][i];
int num=0;
for(int i=start;i<finish;i++)num+=distance[i-1];
bool kawa=0;
for(int i=0;i<2&&!kawa&&num<41;i++)if(time[i][0]==18||time[i][0]==17&&time[i][1]>29||time[i][0]==19&&time[i][1]<31)kawa=1;
num=money[start-1][finish-start-1];
if(kawa){
num/=2;
if(num%50!=0)num+=25;
}
cout<<num<<endl;
}
} |
#include <iostream>
using namespace std;
int main(){
int discount[2]={17*60+30,19*60+30};
int D[7]={0,6,13,18,23,43,58};
int C[7][7]={
{0,300,500,600,700,1350,1650},
{0,0,350,450,600,1150,1500},
{0,0,0,250,400,1000,1350},
{0,0,0,0,250,850,1300},
{0,0,0,0,0,600,1150},
{0,0,0,0,0,0,500},
};
int in,out;
while(cin>>in,in){
int h1,m1,h2,m2,fare;
cin>>h1>>m1;
cin>>out;
cin>>h2>>m2;
if(in>out){
int tmp=in;
in=out;
in=tmp;
}
int d=D[out-1]-D[in-1];
int min1=h1*60+m1,min2=h2*60+m2;
if(((discount[0]<=min1&&min1<=discount[1])||(discount[0]<=min2&&min2<=discount[1]))&&d<=40) fare=(C[in-1][out-1]/2+49)/50*50;
else fare=C[in-1][out-1];
cout<<fare<<endl;
}
return 0;
} |
#include<iostream>
using namespace std;
int main(){
int dist[8] = {0, 0, 6, 13, 18, 23, 43, 58};
int fee[8][8] = {};
fee[1][2] = 300; fee[2][3] = 350; fee[3][4] = 250; fee[4][5] = 250; fee[5][6] = 600; fee[6][7] = 500;
fee[1][3] = 500; fee[2][4] = 450; fee[3][5] = 400; fee[4][6] = 850; fee[5][7] = 1150;
fee[1][4] = 600; fee[2][5] = 600; fee[3][6] = 1000; fee[4][7] = 1300;
fee[1][5] = 700; fee[2][6] = 1150; fee[3][7] = 1350;
fee[1][6] = 1350; fee[2][7] = 1500;
fee[1][7] = 1650;
int d, hd, md, a, ha, ma;
while(1){
cin >> d;
if(d == 0) break;
cin >> hd >> md >> a >> ha >> ma;
hd = hd*100 + md;
ha = ha*100 + ma;
int distance = dist[a] - dist[d];
int ans = fee[d][a];
if(distance <= 40){
if((1730 <= hd && hd <= 1930) || (1730 <= ha && ha <= 1930)){
ans /= 2;
ans = (ans % 50 == 0) ? ans : (ans/50+1)*50;
}
}
cout << ans << endl;
}
return 0;
}
|
#include<iostream>
#define IC_MAX 7
using namespace std;
int main()
{
const int val[IC_MAX][IC_MAX]={
{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}
};
const int dist[IC_MAX][IC_MAX] = {
{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}
};
while(true){
int ans = 0;
int start, end;
int start_h, end_h, start_m, end_m;
int start_time, end_time;
cin>>start;
if( start == 0 )
break;
cin>>start_h>>start_m>>end>>end_h>>end_m;
--start;--end;
start_time = start_h * 100 + start_m;
end_time = end_h * 100 + end_m;
ans = val[start][end];
if( dist[start][end] <= 40 &&
(1730 <= start_time && start_time <= 1930) ||
(1730 <= end_time && end_time <= 1930) ){
ans /= 2;
}
if( ans % 50 != 0 ){
ans = (ans / 50 + 1) * 50;
}
cout << ans << endl;
}
return 0;
} |
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;
typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;
template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
os << *it_i << ", ";
}
return os;
}
bool check( int hh, int mm ) {
if ( hh == 17 ) {
return mm >= 30;
} else if ( hh == 19 ) {
return mm <= 30;
}
return hh == 18;
}
const int T[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 a, b, h1, m1, h2, m2;
while ( cin >> a && a ) {
cin >> h1 >> m1 >> b >> h2 >> m2;
bool flag = check( h1, m1 ) || check( h2, m2 );
a --;
b --;
int price = T[min(a,b)][max(a,b)];
int dist = T[max(a,b)][min(a,b)];
if ( flag && dist <= 40 ) price /= 2;
if ( price % 50 > 0 ) price += 50;
price -= price % 50;
cout << price << endl;
}
return 0;
} |
// AOJ 0163
#include <iostream>
using namespace std;
int main(void)
{
int data[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}};
int start, end, st[2], et[2];
while (cin >> start, start){
cin >> st[0] >> st[1];
cin >> end >> et[0] >> et[1];
start--; end--;
bool f = false;
if (17 <= st[0] && st[0] <= 19){
if (st[0] == 18) f = true;
else if ((st[0] == 17 && 30 <= st[1]) || (st[0] == 19 && 30 >= st[1])){
f = true;
}
}
if (17 <= et[0] && et[0] <= 19){
if (et[0] == 18) f = true;
else if ((et[0] == 17 && 30 <= et[1]) || (et[0] == 19 && 30 >= et[1])){
f = true;
}
}
if (start < end) swap(start, end);
int k = data[start][end];
int ret = data[end][start];
if (40 < k) f = false;
ret /= 50.0;
if (f){
if (ret % 2) ret++;
ret /= 2;
}
cout << (int)(ret * 50) << endl;
}
return 0;
} |
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main(){
int i,j,n,a[8][8];
a[1][2] = a[2][1] = 300;
a[2][3] = a[3][2] = 350;
a[6][7] = a[7][6] = a[1][3] = a[3][1] = 500;
a[4][5] = a[5][4] = a[3][4] = a[4][3] = 250;
a[2][4] = a[4][2] = 450;
a[5][6] = a[6][5] = a[2][5] = a[5][2] = a[1][4] = a[4][1] = 600;
a[3][5] = a[5][3] = 400;
a[5][1] = a[1][5] = 700;
a[4][6] = a[6][4] = 850;
a[3][6] = a[6][3] = 1000;
a[5][7] = a[7][5] = a[2][6] = a[6][2] = 1150;
a[3][7] = a[7][3] = a[1][6] = a[6][1] = 1350;
a[4][7] = a[7][4] = 1300;
a[2][7] = a[7][2] = 1500;
a[1][7] = a[7][1] = 1650;
while(1){
int ic[2],h[2],m[2],t[2],ans,ans2;
cin >> ic[0];
if(ic[0] == 0) break;
cin >> h[0] >> m[0];
cin >> ic[1];
cin >> h[1] >> m[1];
ans = a[ic[0]][ic[1]];
for(i=0;i<2;i++){
if(h[i] == 17 && m[i] >= 30 || h[i] == 18 || h[i] == 19 && m[i] <= 30){
if(ic[0] == 1 && ic[1] == 6 || ic[0] == 6 && ic[1] == 1);
else if(ic[0] == 1 && ic[1] == 7 || ic[0] == 7 && ic[1] == 1);
else if(ic[0] == 2 && ic[1] == 7 || ic[0] == 7 && ic[1] == 2);
else if(ic[0] == 3 && ic[1] == 7 || ic[0] == 7 && ic[1] == 3);
else{
ans /= 2;
ans2 = ans;
while(ans2 > 50) ans2 -= 50;
ans += 50 - ans2;
break;
}
}
}
cout << ans << endl;
}
return 0;
} |
#include <iostream>
using namespace std;
#define INF 1 << 28
int fee[7][7] = {
{INF, 300, 500, 600, 700, 1350, 1650},
{300, INF, 350, 450, 600, 1150, 1500},
{500, 350, INF, 250, 400, 1000, 1350},
{600, 450, 250, INF, 250, 850, 1300},
{700, 600, 400, 250, INF, 600, 1150},
{1350, 1150, 1000, 850, 600, INF, 500},
{1650, 1500, 1350, 1300, 1150, 500, INF}
};
int dist[7][7] = {
{INF, 6, 13, 18, 23, 43, 58},
{6, INF, 7, 12, 17, 37, 52},
{13, 7, INF, 5, 10, 30, 45},
{18, 12, 5, INF, 5, 25, 40},
{23, 17, 10, 5, INF, 20, 35},
{43, 37, 30, 25, 20, INF, 15},
{58, 52, 45, 40, 35, 15, INF}
};
bool in_bargain_time(int h, int m) {
return (17 * 60+ 30 <= h * 60 + m && h * 60 + m <= 19 * 60 + 30);
}
int main() {
int from, to, hf, mf, ht, mt;
while (cin >> from, from) {
cin >> hf >> mf >> to >> ht >> mt;
if ( (in_bargain_time(hf, mf) || in_bargain_time(ht, mt)) && dist[from-1][to-1] <= 40) {
cout << (fee[from-1][to-1] / 2 + 49) / 50 * 50 << endl;
} else {
cout << fee[from-1][to-1] << endl;
}
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int p, q, h, m, s, t, u, c;
int l = 17 * 60 + 30;
int r = 19 * 60 + 30;
bool b;
int a[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}
};
while (1) {
cin >> p;
if (!p) break;
--p;
cin >> h >> m;
s = 60 * h + m;
cin >> q;
--q;
cin >> h >> m;
t = 60 * h + m;
b = false;
if (s>=l && s<=r) b = true;
else if (t>=l && t<=r) b = true;
if (p > q) {
u = p;
p = q;
q = u;
}
if (a[q][p] > 40) b = false;
c = a[p][q];
if (b) {
c /= 2;
if (c % 50) {
c += 50 - (c % 50);
}
}
cout << c << endl;
}
return 0;
} |
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
int data[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 s;
for(;cin>>s,s;)
{
int h,m,e;
int start,end;
cin>>h>>m;
start=h*60+m;
cin>>e;
cin>>h>>m;
end=h*60+m;
if(s>e)
swap(s,e);
s--;e--;
int ans;
if((start>=17*60+30||end<=19*60+30)&&data[e][s]<=40)
ans=data[s][e]/2;
else
ans=data[s][e];
for(;ans%50!=0;)
ans++;
cout<<ans<<endl;
}
} |
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
int vl[6][7]={
{0,300,500,600,700,1350,1650},
{0,0,350,450,600,1150,1500},
{0,0,0,250,400,1000,1350},
{0,0,0,0,250,850,1300},
{0,0,0,0,0,600,1150},
{0,0,0,0,0,0,500}
};
int dis[7]={0,6,13,18,23,43,58};
int t,m,pos1,pos2;
while(scanf("%d",&pos1),pos1){
bool flag=false;
scanf("%d%d",&t,&m);
t=t*100+m;
if(t>=1730&&t<=1930)flag=true;
scanf("%d%d%d",&pos2,&t,&m);
t=t*100+m;
if(t>=1730&&t<=1930)flag=true;
if(pos1>pos2)swap(pos1,pos2);
pos1--;pos2--;
int ans=vl[pos1][pos2];
if(dis[pos2]-dis[pos1]>40)flag=false;
if(flag){
if(ans%100){
ans=(ans-50)/2+50;
}
else ans/=2;
}
printf("%d\n",ans);
}
return 0;
} |
#include<stdio.h>
int main(){
int st1,st2;
int h1,h2,m1,m2;
int n[8][8]={
{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,052,45,40,35,15,0},
};
while(1){
scanf("%d",&st1);if(st1==0)break;
scanf("%d %d",&h1,&m1);
scanf("%d",&st2);
scanf("%d %d",&h2,&m2);
int t1=100*h1+m1;int t2=100*h2+m2;
int T1=st1,T2=st2,S=0;
if(st1>=st2){T1=st2;T2=st1;}
if(((t1>=1730&&t1<=1930)||(t2<=1930&&t2>=1730))&&n[T2-1][T1-1]<=40)
{S=(n[T1-1][T2-1])/2;}
else S=(n[T1-1][T2-1]);
if(S%50!=0){
int QQ=S/50;QQ++;S=QQ*50;
}
printf("%d\n",S);
}
return 0;
} |
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
using namespace std;
typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair
template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }
int cost[8][8]={
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 300, 500, 600, 700,1350,1650},
{ 0, 300, 0, 350, 450, 600,1150,1500},
{ 0, 500, 350, 0, 250, 400,1000,1350},
{ 0, 600, 450, 250, 0, 250, 850,1300},
{ 0, 700, 600, 400, 250, 0, 600,1150},
{ 0,1350,1150,1000, 850, 600, 0, 500},
{ 0,1650,1500,1350,1300,1150, 500, 0}
};
int dis[8][8]={
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 6,13,18,23,43,58},
{ 0, 6, 0, 7,12,17,37,52},
{ 0,13, 7, 0, 5,10,30,45},
{ 0,18,12, 5, 0, 5,25,40},
{ 0,23,17,10, 5, 0,20,35},
{ 0,43,37,30,25,20, 0,15},
{ 0,58,52,45,40,35,15, 0}
};
int main() {
int n1,n2,h1,h2,m1,m2;
while(n1=in()){
cin>>h1>>m1>>n2>>h2>>m2;
int c=cost[n1][n2];
int d=dis[n1][n2];
int time1=h1*60+m1;
int time2=h2*60+m2;
if(d<=40&&(17*60+30<=time1&&time1<=19*60+30||17*60+30<=time2&&time2<=19*60+30)){
c/=2;
if(c%50){
c+=50-c%50;
}
}
cout<<c<<endl;
}
return 0;
} |
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
using namespace std;
#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }
typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
typedef pair<int,int> P;
bool hangaku(int h,int m){
if(h == 18){
return true;
}else if(h == 17){
return m >= 30;
}else if(h == 19){
return m <= 30;
}else{
return false;
}
}
int main(){
int s,g;
int kyori[8] = {0,0,6,13,18,23,43,58};
map<P,int> price;
price[P(1,2)] = 300;
price[P(1,3)] = 500;
price[P(1,4)] = 600;
price[P(1,5)] = 700;
price[P(1,6)] = 1350;
price[P(1,7)] = 1650;
price[P(2,3)] = 350;
price[P(2,4)] = 450;
price[P(2,5)] = 600;
price[P(2,6)] = 1150;
price[P(2,7)] = 1500;
price[P(3,4)] = 250;
price[P(3,5)] = 400;
price[P(3,6)] = 1000;
price[P(3,7)] = 1350;
price[P(4,5)] = 250;
price[P(4,6)] = 850;
price[P(4,7)] = 1300;
price[P(5,6)] = 600;
price[P(5,7)] = 1150;
price[P(6,7)] = 500;
while(cin>>s,s){
int h1,m1,h2,m2;
cin>>h1>>m1>>g>>h2>>m2;
if(s > g) swap(s,g);
int ans = price[P(s,g)];
if(hangaku(h1,m1) || hangaku(h2,m2)){
if(kyori[g]-kyori[s] <= 40){
if(ans % 100){
ans = (ans+50)/2;
}else{
ans /= 2;
}
}
}
cout<<ans<<endl;
}
return 0;
} |
#include<iostream>
using namespace std;
int main(){
long p[8][8]={{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}};
long s,e,hs,ms,he,me,a,b,c;
while(cin>>s){
if(s==0)break;
cin>>hs>>ms>>e>>he>>me;
if(s>e){a=s;s=e;e=a;}
hs*=60;hs+=ms;
he*=60;he+=me;
a=(hs-1050)*(hs-1170);
b=(he-1050)*(he-1170);
if(a<=0||b<=0)c=1;else c=0;
if(p[e-1][s-1]<=40&&c==1)cout<<((p[s-1][e-1]/50+1)/2)*50<<endl;
else cout<<p[s-1][e-1]<<endl;
}
return 0;
} |
#include <iostream>
#include <string>
using namespace std;
int s2i(string a,string b){
int h=0,m=0;
for(int i=0;i<a.size();i++) h*=10,h+=a[i]-'0';
for(int i=0;i<b.size();i++) m*=10,m+=b[i]-'0';
return h*60+m;
}
int main() {
int fee[7][7]={
{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}};
int D[7][7]={
{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}};
int s,g;
string a[2],b[2];
while(1 ){
cin>> s;
if(s==0)break;
cin >> a[0] >> a[1];
cin >> g;
cin >> b[0]>>b[1];
s--,g--;
int ans = fee[s][g];
int st = s2i(a[0],a[1]);
int gt = s2i(b[0],b[1]);
if(D[s][g]<=40 && ((60*17+30<= st&&st<=60*19+30)||(60*17+30<=gt&><=60*19+30)))ans/=2;
if(ans%50!=0) ans = (ans/50+1)*50;
cout << ans <<endl;
}
return 0;
} |
#include <cstdio>
#include <cmath>
const int price[7][7] = {
{-1,300,500,600,700,1350,1650},
{-1,-1,350,450,600,1150,1500},
{-1,-1,-1,250,400,1000,1350},
{-1,-1,-1,-1,250,850,1300},
{-1,-1,-1,-1,-1,600,1150},
{-1,-1,-1,-1,-1,-1,500}
};
const int dist[7][7] = {
{-1,6,13,18,23,43,58},
{-1,-1,7,12,17,37,52},
{-1,-1,-1,5,10,30,45},
{-1,-1,-1,-1,5,25,40},
{-1,-1,-1,-1,-1,20,35},
{-1,-1,-1,-1,-1,-1,15}
};
const int start = 17*60 + 30 , end = 19*60 + 30;
int main(){
int sIC,sh,sm,tIC,th,tm;
while(scanf("%d" ,&sIC) ,sIC){
scanf("%d%d" ,&sh ,&sm);
scanf("%d%d%d" ,&tIC ,&th ,&tm);
sIC--; tIC--;
bool ok1 = false,ok2 = false;
int ssum = sh*60 + sm , tsum = th*60 + tm;
if((start <= ssum && ssum <= end) ||
(start <= tsum && tsum <= end)) ok1 = true;
if(dist[sIC][tIC] <= 40) ok2 = true;
int ans = price[sIC][tIC];
if(ok1 && ok2){
ans = (ans / 50 + 1) / 2;
ans *= 50;
}
printf("%d\n" ,ans);
}
return 0;
} |
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int ck[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 eic;
while(cin>>eic,eic){
int eh,em,tic,th,tm;
cin>>eh>>em>>tic>>th>>tm;
if(eic>tic)swap(eic,tic);
--eic,--tic;
int kyori=ck[tic][eic];
if(((60*eh+em>=17*60+30 && 60*eh+em<=19*60+30) ||
(60*th+tm>=17*60+30 && 60*th+tm<=19*60+30)) &&
kyori<=40)cout<<(ck[eic][tic]/2+49)/50*50;
else cout<<ck[eic][tic];
cout<<endl;
}
} |
#include <iostream>
using namespace std;
int table[ 8 ][ 8 ] = {
{ 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 300, 500, 600, 700, 1350, 1650 },
{ 0, 6, 0, 350, 450, 600, 1150, 1500 },
{ 0, 13, 7, 0, 250, 400, 1000, 1350 },
{ 0, 18, 12, 5, 0, 250, 850, 1300 },
{ 0, 23, 17, 10, 5, 0, 600, 1150 },
{ 0, 43, 37, 30, 25, 20, 0, 500 },
{ 0, 58, 52, 45, 40, 35, 15, 0 }
};
int main()
{
int s, e;
int sh, sm, eh, em;
while( cin >> s && s ){
cin >> sh >> sm;
cin >> e;
cin >> eh >> em;
int st = sh * 100 + sm;
int et = eh * 100 + em;
if( s > e ){
int t = s;
s = e;
e = t;
}
int cost = table[ s ][ e ];
if( ( ( st >= 1730 && st <= 1930 ) || ( et >= 1730 && et <= 1930 ) )
&& ( table[ e ][ s ] <= 40 ) ){
cost = static_cast<int>( ( ( cost / 100.0 ) + 0.9 ) ) * 50;
}
cout << cost << endl;
}
return 0;
} |
#include <iostream>
using namespace std;
int abs(int i)
{
return ( i < 0 ? -i : i );
}
int km_to_yen(int km)
{
switch(km)
{
case 5:
return 250;
case 6:
return 300;
case 7:
return 350;
case 10:
return 400;
case 12:
return 450;
case 13:
case 15:
return 500;
case 17:
case 18:
case 20:
return 600;
case 23:
return 700;
case 25:
return 850;
case 30:
return 1000;
case 35:
case 37:
return 1150;
case 40:
return 1300;
case 43:
case 45:
return 1350;
case 52:
return 1500;
case 58:
return 1650;
}
}
int main()
{
int ic_km[8] = { 0, 0, 6, 13, 18, 23, 43, 58, };
while (true)
{
int from_num;
int from_hour, from_min;
cin >> from_num;
if ( from_num == 0 ) break;
cin >> from_hour >> from_min;
int from_time = from_hour*100 + from_min;
int to_num;
int to_hour, to_min;
cin >> to_num;
cin >> to_hour >> to_min;
int to_time = to_hour*100 + to_min;
int km_diff = abs(ic_km[to_num] - ic_km[from_num]);
int fare = km_to_yen(km_diff);
if ( ( ( 1730 <= from_time && from_time <= 1930 ) ||
( 1730 <= to_time && to_time <= 1930 ) ) &&
( km_diff <= 40 ) )
{
fare /= 2;
if ( fare % 50 != 0 )
{
fare = ( fare / 50 + 1 ) * 50;
}
}
cout << fare << endl;
}
} |
#include<iostream>
using namespace std;
int dist[7][7] = { {0,0,0,0,0,0,0},{6,0,0,0,0,0,0},{13,7,0,0,0,0,0},{18,12,5,0,0,0,0},{23,17,10,5,0,0,0},{43,37,30,25,20,0,0},{58,52,45,40,35,15,0} };
int money[7][7] = { {0,300,500,600,700,1350,1650},{0,0,350,450,600,1150,1500},{0,0,0,250,400,1000,1350},{0,0,0,0,250,850,1300},{0,0,0,0,0,600,1150},{0,0,0,0,0,0,500},{0,0,0,0,0,0,0} };
int a, b, c, d, e, f;
int main() {
while (true) {
cin >> a; if (a == 0) { break; }cin >> b >> c >> d >> e >> f; b = b * 60 + c; e = e * 60 + f; a--; d--;
for (int i = 0; i < 7; i++) { for (int j = 0; j < 7; j++) { if (dist[i][j] == 0) { dist[i][j] = dist[j][i]; }if (money[i][j] == 0) { money[i][j] = money[j][i]; } } }
if (((b >= 1050 && b <= 1170) || (e >= 1050 && e <= 1170)) && dist[a][d] <= 40) { if (money[a][d] % 100 == 0) { cout << money[a][d] / 2 << endl; } else { cout << money[a][d] / 2 + 25 << endl; } }
else { cout << money[a][d] << endl; }
}
} |
#include "bits/stdc++.h"
using namespace std;
#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define MP(a, b) make_pair(a, b)
#define F first
#define S second
#define INF 1 << 30
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;
int n, m;
vector<pi> s;
int dp[1024];
using namespace std;
using namespace std;
int main() {
char c1[2],c2[2];
int h,m,ic[2],f[2],i,k;
int g[7][7]={{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}};
while(true) {
for (i=0;i<2;i++) {
cin >> ic[i];
if (ic[i]==0) return 0;
ic[i]--;
cin >> c1 >> c2;
h=(c1[0]-'0')*10+(c1[1]-'0');
m=(c2[0]-'0')*10+(c2[1]-'0');
f[i]=(h==17 && m>29) || (h==18) || (h==19 && m<31);
}
k=g[ic[0]][ic[1]];
if(k<1350)
if (f[0]+f[1]>0) k=k % 100>0 ? k/2+25:k/2;
cout << k << endl;
}
return 0;
} |
#include <iostream>
using namespace std;
int a[7][7] = {
{ 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}
};
int d[7][7] = {
{ 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}
};
int main(int argc, char **argv)
{
int m1, s1, m2, s2, ic1, ic2;
while(1){
cin >> ic1;
if(ic1 == 0){
break;
}
cin >> m1 >> s1;
cin >> ic2;
cin >> m2 >> s2;
ic1--;
ic2--;
if(!((m1 == 17 && s1 >= 30)||(m1 == 18)||(m1 == 19 && s1 <= 30))
&&!((m2 == 17 && s2 >= 30)||(m2 == 18)||(m2 == 19 && s2 <= 30))){
cout << a[ic1][ic2] << endl;
continue;
}
if(d[ic1][ic2] <= 40){
m1 = a[ic1][ic2]/2;
m2 = m1 % 50;
if(m2 != 0){
m1 = m1 - m2 + 50;
}
cout << m1 << endl;
} else {
cout << a[ic2][ic1] << endl;
}
}
return 0;
} |
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
int u,d;
int s = 17*60+30;
int g = 19*60 + 30;
int table[7][7];
table[0][1]=300;
table[0][2]=500;
table[0][3]=600;
table[0][4]=700;
table[0][5]=1350;
table[0][6]=1650;
table[1][2]=350;
table[1][3]=450;
table[1][4]=600;
table[1][5]=1150;
table[1][6]=1500;
table[2][3]=250;
table[2][4]=400;
table[2][5]=1000;
table[2][6]=1350;
table[3][4]=250;
table[3][5]=850;
table[3][6]=1300;
table[4][5]=600;
table[4][6]=1150;
table[5][6]=500;
table[1][0]=6;
table[2][0]=13;
table[3][0]=18;
table[4][0]=23;
table[5][0]=43;
table[6][0]=58;
table[2][1]=7;
table[3][1]=12;
table[4][1]=17;
table[5][1]=37;
table[6][1]=52;
table[3][2]=5;
table[4][2]=10;
table[5][2]=30;
table[6][2]=45;
table[4][3]=5;
table[5][3]=25;
table[6][3]=40;
table[5][4]=20;
table[6][4]=35;
table[6][5]=15;
while(cin>>u&&u!=0){
u--;
int h1,m1,h2,m2;
cin>>h1>>m1;
cin>>d;
d--;
cin>>h2>>m2;
int st=h1*60+m1;
int gt=h2*60+m2;
if((st>=s&&st<=g)||(gt>=s&><=g)){
// ツ板シツ額
int idx1=min(u,d);
int idx2=max(u,d);
int dis=table[idx2][idx1];
if(dis<=40){
int mo=table[idx1][idx2]/2;
if(mo%50!=0){
mo-=mo%50;
mo+=50;
}
cout<<mo<<endl;
}
else
cout<<table[idx1][idx2]<<endl;
}
else{
int idx1=min(u,d);
int idx2=max(u,d);
cout<<table[idx1][idx2]<<endl;
}
}
return 0;
} |
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;
int table[][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 to, from;
int d, hd, md,sd;
int a, ha, ma,sa;
while (cin >> d, d) {
cin >> hd >> md;
cin >> a >> ha >> ma;
d--, a--;
to = 19 * 60 * 60 + 30 * 60;
from = 17 * 60 * 60 + 30 * 60;
sd = hd * 60 * 60 + md * 60;
sa = ha * 60 * 60 + ma * 60;
if (from <= sd && to >= sa || from >= sd && to >= sa || from <= sd && to <= sa) {
if (table[a][d] <= 40) {
int ans = table[d][a] / 2;
if (ans % 50 != 0)ans += 25;
cout << ans << endl;
}
else cout << table[d][a] << endl;
}
else
cout << table[d][a] << endl;
}
return 0;
} |
#include <bits/stdc++.h>
using namespace std;
int main() {
int d[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}};
int a,b;
while(cin >> a && a) {
int x[2],y[2];
cin >> x[0] >> x[1] >> b >> y[0] >> y[1];
a--,b--;
if(a>b) swap(a,b);
int m1=x[0]*60+x[1],m2=y[0]*60+y[1];
int c=d[a][b];
if((m1>=17*60+30&&m1<=19*60+30||m2>=17*60+30&&m2<=19*60+30)&&d[b][a]<=40) {
c/=2;
if(c%50) c+=50-c%50;
}
cout << c << endl;
}
return 0;
}
|
#include <iostream>
#include <vector>
using namespace std;
typedef pair<int, int> P;
int main() {
vector< vector<P> > data(8, vector<P>(8, P(0, 0)));
data[1][2] = data[2][1] = P(6, 300);
data[1][3] = data[3][1] = P(13, 500);
data[1][4] = data[4][1] = P(18, 600);
data[1][5] = data[5][1] = P(23, 700);
data[1][6] = data[6][1] = P(43, 1350);
data[1][7] = data[7][1] = P(58, 1650);
data[2][3] = data[3][2] = P(7, 350);
data[2][4] = data[4][2] = P(12, 450);
data[2][5] = data[5][2] = P(17, 600);
data[2][6] = data[6][2] = P(37, 1150);
data[2][7] = data[7][2] = P(52, 1500);
data[3][4] = data[4][3] = P(5, 250);
data[3][5] = data[5][3] = P(10, 400);
data[3][6] = data[6][3] = P(30, 1000);
data[3][7] = data[7][3] = P(45, 1350);
data[4][5] = data[5][4] = P(5, 250);
data[4][6] = data[6][4] = P(25, 850);
data[4][7] = data[7][4] = P(40, 1300);
data[5][6] = data[6][5] = P(20, 600);
data[5][7] = data[7][5] = P(35, 1150);
data[6][7] = data[7][6] = P(15, 500);
int s, g;
while (cin >> s) {
if (s == 0) {
break;
}
int sh, sm;
cin >> sh >> sm;
int gh, gm;
cin >> g;
cin >> gh >> gm;
int mm = data[s][g].second;
bool hantei = true;
if (data[s][g].first <= 40) {
if (sh == 18) {
if (mm % 100 == 50) {
mm += 50;
}
mm /= 2;
hantei = false;
} else if (sh == 17) {
if (sm >= 30) {
if (mm % 100 == 50) {
mm += 50;
}
mm /= 2;
hantei = false;
}
} else if (sh == 19) {
if (sm <= 30) {
if (mm % 100 == 50) {
mm += 50;
}
mm /= 2;
hantei = false;
}
}
if (hantei) {
if (gh == 18) {
if (mm % 100 == 50) {
mm += 50;
}
mm /= 2;
} else if (gh == 17) {
if (gm >= 30) {
if (mm % 100 == 50) {
mm += 50;
}
mm /= 2;
}
} else if (gh == 19) {
if (gm <= 30) {
if (mm % 100 == 50) {
mm += 50;
}
mm /= 2;
}
}
}
}
cout << mm << endl;
}
return 0;
} |
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int h[6][7]={
{0,300,500,600,700,1350,1650},
{0, 0,350,450,600,1150,1500},
{0, 0, 0,250,400,1000,1350},
{0, 0, 0, 0,250, 850,1300},
{0, 0, 0, 0, 0, 600,1150},
{0, 0, 0, 0, 0, 0, 500}
};
int main(){
int n,m;
while(cin>>n,n){
int a,b;
int m1,m2;
cin>>a>>b;
m1=a*100+b;
cin>>m;
cin>>a>>b;
m2=a*100+b;
if(n>m)swap(n,m);
bool han=true;
if(m2<1730||1950<m1||(m1<1730&&1930<m2))han=false;
if((m==7&&n<4)||(m==6&&n==1))han=false;
int ans=h[n-1][m-1];
if(han)ans/=2;
ans=(ans+49)-(ans+49)%50;
cout<<ans<<endl;
}
} |
#include <iostream>
using namespace std;
int m[7][7][2] = {
{{0,0},{6,300},{13,500},{18,600},{23,700},{43,1350},{58,1650}},
{{6,300},{0,0},{7,350},{12,450},{17,600},{37,1150},{52,1500}},
{{13,500},{7,350},{0,0},{5,250},{10,400},{30,1000},{45,1350}},
{{18,600},{12,450},{5,250},{0,0},{5,250},{25,850},{40,1300}},
{{23,700},{17,600},{10,400},{5,250},{0,0},{20,600},{35,1150}},
{{43,1350},{37,1150},{30,1000},{25,850},{20,600},{0,0},{15,500}},
{{58,1650},{52,1500},{45,1350},{40,1300},{35,1150},{15,500},{0,0}},
};
int main()
{
int s,g,hs,ms,hg,mg,t,c;
bool f;
for(;;){
cin >> s;
if(s==0) break;
cin >> hs >> ms;
cin >> g;
cin >> hg >> mg;
f = false;
t = hs * 60 + ms;
if(1050<= t && t<=1170) f = true;
t = hg * 60 + mg;
if(1050<= t && t<=1170) f = true;
if(m[s-1][g-1][0] > 40) f = false;
c = m[s-1][g-1][1];
if(f){
c /= 2;
if(c % 50 != 0) {
c = c - (c % 50) + 50;
}
}
cout << c << endl;
}
return 0;
} |
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
int main(){
int c[8][8];
int d[8][8];
for(int i = 0; i < 8; i++){
for(int j = 0; j < 8; j++){
c[i][j] = 0;
d[i][j] = 0;
}
}
c[1][2] = 300;
d[1][2] = 6;
c[1][3] = 500;
c[2][3] = 350;
d[1][3] = 13;
d[2][3] = 7;
c[1][4] = 600;
c[2][4] = 450;
c[3][4] = 250;
d[1][4] = 18;
d[2][4] = 12;
d[3][4] = 5;
c[1][5] = 700;
c[2][5] = 600;
c[3][5] = 400;
c[4][5] = 250;
d[1][5] = 23;
d[2][5] = 17;
d[3][5] = 10;
d[4][5] = 5;
c[1][6] = 1350;
c[2][6] = 1150;
c[3][6] = 1000;
c[4][6] = 850;
c[5][6] = 600;
d[1][6] = 43;
d[2][6] = 37;
d[3][6] = 30;
d[4][6] = 25;
d[5][6] = 20;
c[1][7] = 1650;
c[2][7] = 1500;
c[3][7] = 1350;
c[4][7] = 1300;
c[5][7] = 1150;
c[6][7] = 500;
d[1][7] = 58;
d[2][7] = 52;
d[3][7] = 45;
d[4][7] = 40;
d[5][7] = 35;
d[6][7] = 15;
for(int i = 0; i < 8; i++){
for(int j = 0; j < 8; j++){
c[i][j] /= 50;;
}
}
while(true){
int d1, d2;
int h, m, time;
bool is_half = false;
bool is_half2 = false;
cin >> d1;
if(d1 == 0){
break;
}
cin >> h >> m;
time = h * 60 + m;
if(time >= 17 * 60 + 30 && time <= 19 * 60 + 30){
is_half = true;
}
cin >> d2;
cin >> h >> m;
time = h * 60 + m;
if(time >= 17 * 60 + 30 && time <= 19 * 60 + 30){
is_half = true;
}
if(d[d1][d2] <= 40){
is_half2 = true;
}
int ans = c[d1][d2];
if(is_half && is_half2){
ans = (ans + 1) / 2;
}
cout << ans * 50 << endl;
}
return 0;
} |
#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 an=s[sc-1][ec-1],S=sh*100+sm,E=eh*100+em;
if(((1730<=S&&S<=1930)||(1730<=E&&E<=1930))&&(s[ec-1][sc-1]<=40))an/=2;
if(an%50)an-=an%50,an+=50;
cout<<an<<endl;
}
return 0;
} |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
int dis[7][7], cost[7][7];
void init() {
dis[0][1] = 6; dis[0][2] = 13, dis[0][3] = 18, dis[0][4] = 23, dis[0][5] = 43, dis[0][6] = 58;
dis[1][2] = 7, dis[1][3] = 12, dis[1][4] = 17, dis[1][5] = 37, dis[1][6] = 52;
dis[2][3] = 5, dis[2][4] = 10, dis[2][5] = 30, dis[2][6] = 45;
dis[3][4] = 5, dis[3][5] = 25, dis[3][6] = 40;
dis[4][5] = 20, dis[4][6] = 35;
dis[5][6] = 15;
cost[0][1] = 300, cost[0][2] = 500, cost[0][3] = 600, cost[0][4] = 700, cost[0][5] = 1350, cost[0][6] = 1650;
cost[1][2] = 350, cost[1][3] = 450, cost[1][4] = 600, cost[1][5] = 1150, cost[1][6] = 1500;
cost[2][3] = 250, cost[2][4] = 400, cost[2][5] = 1000, cost[2][6] = 1350;
cost[3][4] = 250, cost[3][5] = 850, cost[3][6] = 1300;
cost[4][5] = 600, cost[4][6] = 1150;
cost[5][6] = 500;
}
bool in_range(int h, int m) {
if (h < 17 || h > 19) return false;
if (h == 17 && m < 30) return false;
if (h == 19 && m > 30) return false;
return true;
}
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
cout << fixed << setprecision(10);
init();
int d, a;
while (cin >> d, d) {
int hd, md, ha, ma;
cin >> hd >> md >> a >> ha >> ma;
d--, a--;
if (d > a) swap(d, a);
bool ok = (dis[d][a] <= 40);
ok &= (in_range(hd, md) || in_range(ha, ma));
cout << (ok ? (cost[d][a] / 2 + 50 - 1) / 50 * 50 : cost[d][a]) << endl;
}
return 0;
}
|
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())
typedef unsigned long long ull;
const int INF = (int)1e8;
int my[7][7] = {{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,800,600,0,500},
{1650,1500,1350,1300,1150,500,0}};
int ds[7][7] = {{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}};
bool half(int len,int l,int r){
if(len > 40) return false;
const int x = 17*60+30,y=19*60+30;
return (x <= l && l <= y) || (x <= r && r <= y);
}
int main(){
int n;
while(cin>>n,n){
int nt; {int a,b; cin>>a>>b; nt = a * 60 + b; }
int m; cin>>m;
int mt; {int a,b; cin>>a>>b; mt = a * 60 + b; }
int len = ds[n-1][m-1];
bool h = half(len,nt,mt);
int mo = my[n-1][m-1];
if(h) mo = ((mo/50+1)/2) * 50;
cout << mo << endl;
}
return 0;
} |
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 1<<30
int main() {
int table[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 ss = 17*60+30;
int tt = 19*60+30;
int s, sh, sm, t, th, tm;
while(cin >> s, s) {
cin >> sh >> sm >> t >> th >> tm;
s--;t--;
if (s>t) swap(s,t);
int ans = table[s][t];
int sss = sh*60+sm;
int ttt = th*60+tm;
if (table[t][s] <= 40) {
if (ss<=sss&&sss<=tt || ss<=ttt&&ttt<=tt) {
ans /= 2;
ans = (ans + 49) / 50 * 50;
}
}
cout << ans << endl;
}
} |
#include<iostream>
using namespace std;
int main(){
int f,t;
int dis[7][7] = { { 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},
{58,52,45,40,35,15, 0} };
int fee[7][7] = { { 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} };
int h,m;
bool flag;
int ans;
while(1){
cin >> f;
if(!f)break;
f--;
flag = false;
cin >> h >> m;
if(h==17 && m>=30)flag = true;
else if(h == 18)flag = true;
else if(h==19 && m<=30)flag = true;
cin >> t;
t--;
cin >> h >> m;
if(h==17 && m>=30)flag = true;
else if(h == 18)flag = true;
else if(h==19 && m<=30)flag = true;
ans = fee[f][t];
if(flag && dis[f][t]<=40){
ans /= 2;
if(ans != (ans/50)*50)ans = (ans/50 + 1)*50;
}
cout << ans << endl;
}
} |
#include <bits/stdc++.h>
using namespace std;
const int t[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}
};
const int B = 17 * 60 + 30, E = 19 * 60 + 30;
int main()
{
int id1, h1, m1;
int id2, h2, m2;
while (scanf("%d", &id1), id1){
scanf("%d %d %d %d %d", &h1, &m1, &id2, &h2, &m2);
if (id1 > id2) swap(id1, id2);
int t1 = h1 * 60 + m1;
int t2 = h2 * 60 + m2;
--id1; --id2;
int v = t[id1][id2];
int l = t[id2][id1];
bool f = true;
if (l > 40) f = false;
if (((B <= t1 && t1 <= E) || (B <= t2 && t2 <= E)) && f){
v /= 2;
int f = !!(v % 50);
v = v / 50 * 50 + f * 50;
}
printf("%d\n", v);
}
return 0;
} |
#include<iostream>
#define N 7
using namespace std;
int cost[N][N];
int dis[N][N];
void InitCost(){
for(int i=0; i<N; i++) cost[i][i] = 0;
cost[0][1] = 300;
cost[0][2] = 500;
cost[0][3] = 600;
cost[0][4] = 700;
cost[0][5] = 1350;
cost[0][6] = 1650;
cost[1][2] = 350;
cost[1][3] = 450;
cost[1][4] = 600;
cost[1][5] = 1150;
cost[1][6] = 1500;
cost[2][3] = 250;
cost[2][4] = 400;
cost[2][5] = 1000;
cost[2][6] = 1350;
cost[3][4] = 250;
cost[3][5] = 850;
cost[3][6] = 1300;
cost[4][5] = 600;
cost[4][6] = 1150;
cost[5][6] = 500;
cost[1][0] = 300;
cost[2][0] = 500;
cost[3][0] = 600;
cost[4][0] = 700;
cost[5][0] = 1350;
cost[6][0] = 1650;
cost[2][1] = 350;
cost[3][1] = 450;
cost[4][1] = 600;
cost[5][1] = 1150;
cost[6][1] = 1500;
cost[3][2] = 250;
cost[4][2] = 400;
cost[5][2] = 1000;
cost[6][2] = 1350;
cost[4][3] = 250;
cost[5][3] = 850;
cost[6][3] = 1300;
cost[5][4] = 600;
cost[6][4] = 1150;
cost[6][5] = 500;
}
void InitDistance(){
for(int i=0; i<N; i++) dis[i][i] = 0;
dis[0][1] = 6;
dis[0][2] = 13;
dis[0][3] = 18;
dis[0][4] = 23;
dis[0][5] = 43;
dis[0][6] = 58;
dis[1][2] = 7;
dis[1][3] = 12;
dis[1][4] = 17;
dis[1][5] = 37;
dis[1][6] = 52;
dis[2][3] = 5;
dis[2][4] = 10;
dis[2][5] = 30;
dis[2][6] = 45;
dis[3][4] = 5;
dis[3][5] = 25;
dis[3][6] = 40;
dis[4][5] = 20;
dis[4][6] = 35;
dis[5][6] = 15;
dis[1][0] = 6;
dis[2][0] = 13;
dis[3][0] = 18;
dis[4][0] = 23;
dis[5][0] = 43;
dis[6][0] = 58;
dis[2][1] = 7;
dis[3][1] = 12;
dis[4][1] = 17;
dis[5][1] = 37;
dis[6][1] = 52;
dis[3][2] = 5;
dis[4][2] = 10;
dis[5][2] = 30;
dis[6][2] = 45;
dis[4][3] = 5;
dis[5][3] = 25;
dis[6][3] = 40;
dis[5][4] = 20;
dis[6][4] = 35;
dis[6][5] = 15;
}
int WhatTime(int h, int m){
if(h < 17 || (h == 17 && m < 30)) return -1;
if(h > 19 || (h == 19 && m > 30)) return 1;
return 0;
}
int HighwayToll(int n, int h1, int m1, int m, int h2, int m2){
int ans;
ans = cost[n][m];
if(dis[n][m] <= 40){
if((WhatTime(h1, m1) == 0 && WhatTime(h2, m2) == 0) ||
(WhatTime(h1, m1) == -1 && WhatTime(h2, m2) == 0) ||
(WhatTime(h1, m1) == 0 && WhatTime(h2, m2) == 1)){
ans /= 2;
if(ans%50 != 0) ans = ans - ans%50 + 50;
}
}
return ans;
}
int main(){
int n, m;
int h1, m1, h2, m2;
InitCost();
InitDistance();
while(1){
cin >> n;
if(n == 0) break;
cin >> h1 >> m1;
cin >> m;
cin >> h2 >> m2;
--n;
--m;
cout << HighwayToll(n, h1, m1, m, h2, m2) << endl;
}
return 0;
} |
// 2011/03/01 Tazoe
#include <iostream>
using namespace std;
int main()
{
int tol[8][8] = {{ -1, -1, -1, -1, -1, -1, -1, -1},
{ -1, 0, 300, 500, 600, 700,1350,1650},
{ -1, 300, 0, 350, 450, 600,1150,1500},
{ -1, 500, 350, 0, 250, 400,1000,1350},
{ -1, 600, 450, 250, 0, 250, 850,1300},
{ -1, 700, 600, 400, 250, 0, 600,1150},
{ -1,1350,1150,1000, 850, 600, 0, 500},
{ -1,1650,1500,1350,1300,1150, 500, 0}};
int dis[8][8] = {{ -1, -1, -1, -1, -1, -1, -1, -1},
{ -1, 0, 6, 13, 18, 23, 43, 58},
{ -1, 6, 0, 7, 12, 17, 37, 52},
{ -1, 13, 7, 0, 5, 10, 30, 45},
{ -1, 18, 12, 5, 0, 5, 25, 40},
{ -1, 23, 17, 10, 5, 0, 20, 35},
{ -1, 43, 37, 30, 25, 20, 0, 15},
{ -1, 58, 52, 45, 40, 35, 15, 0}};
while(true){
int fic;
cin >> fic;
if(fic==0)
break;
int fh, fm;
cin >> fh >> fm;
int tic;
cin >> tic;
int th, tm;
cin >> th >> tm;
int fhm = fh*100+fm;
int thm = th*100+tm;
if(((fhm>=1730&&fhm<=1930)||(thm>=1730&&thm<=1930))&&dis[fic][tic]<=40)
cout << (tol[fic][tic]/50+1)/2*50 << endl;
else
cout << tol[fic][tic] << endl;
}
return 0;
} |
#include<iostream>
#include<algorithm>
#define S 1050 //1050min = 17:30 //
#define G 1170 //1170min = 19:30 //
using namespace std;
int kiriage(int);
int main(){
int tmp[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 sIC,sh,sm,gIC,gh,gm,smin,gmin,cost;
while(cin >> sIC && sIC){
cin >> sh >> sm >> gIC >> gh >> gm;
smin = sh * 60 + sm;
gmin = gh * 60 + gm;
if(sIC>gIC)swap(sIC,gIC);
cout << ((((smin >= S && smin <= G) || (gmin >= S && gmin <= G)) && tmp[gIC-1][sIC-1]<=40) ?
kiriage(tmp[sIC-1][gIC-1]/2) : tmp[sIC-1][gIC-1]) << endl;
}
}
int kiriage(int cost){
return (cost%50==0?cost:cost/50*50+50);
} |
#include<stdio.h>
int main()
{
const int cost[7][7] = {
{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},
},distance[7][7] = {
{ 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,},
};
int toIndex,fromIndex,fromH,fromM,toH,toM,c,d;
while(scanf("%d",&fromIndex),fromIndex)
{
scanf("%d%d%d%d%d",&fromH, &fromM, &toIndex, &toH, &toM);
c=cost[fromIndex-1][toIndex-1];
d=distance[fromIndex-1][toIndex-1];
if( (
(fromH==18 || (fromH==17&&fromM>=30) || (fromH==19&&fromM<=30)) ||
(toH==18 || (toH==17&&toM>=30) || (toH==19&&toM<=30))
) && d<=40)
printf("%d\n", c%100 + c/100*50 );
else printf("%d\n", c);
}
return 0;
} |
#include<bits/stdc++.h>
using namespace std;
int main()
{
int start,finish;
while(cin>>start,start){
int time[2][2];
for(int i=0;i<2;i++)cin>>time[0][i];
cin>>finish;
if(start>finish)swap(start,finish);
for(int i=0;i<2;i++)cin>>time[1][i];
int num=0,distance[]={6,7,5,5,20,15},money[6][6]={{300,500,600,700,1350,1650},{350,450,600,1150,1500},{250,400,1000,1350},{250,850,1300},{600,1150},{500}};
for(int i=start-1;i<finish-1;i++)num+=distance[i];
bool kawa=0;
for(int i=0;i<2&&!kawa&&num<41;i++)if(time[i][0]==18||time[i][0]==17&&time[i][1]>29||time[i][0]==19&&time[i][1]<31)kawa=1;
num=money[start-1][finish-start-1];
if(kawa){
num/=2;
if(num%50!=0)num+=25;
}
cout<<num<<endl;
}
} |
#include<cstdio>
using namespace std;
int main(void)
{
int hyou[8][8]={{0,0,0,0,0,0,0,0},
{0,0,300,500,600,700,1350,1650},
{0,6,0,350,450,600,1150,1500},
{0,13,7,0,250,400,1000,1350},
{0,18,12,5,0,250,850,1300},
{0,23,17,10,5,0,600,1150},
{0,43,37,30,25,20,0,500},
{0,58,52,45,40,35,15,0}};
int ic1,ic2,h1,h2,m1,m2,i,j,wk,t1,t2,kin;
while(1) {
scanf("%d",&ic1);
if(ic1==0) break;
scanf("%d %d",&h1,&m1);
scanf("%d",&ic2);
scanf("%d %d",&h2,&m2);
if(ic1>ic2) {
wk=ic1;
ic1=ic2;
ic2=wk;
}
t1=h1*60+m1;
t2=h2*60+m2;
if(((t1>=17*60+30 && t1<=19*60+30) || (t2>=17*60+30 && t2<=19*60+30)) && hyou[ic2][ic1]<=40) {
if(hyou[ic1][ic2]%100!=0) {
kin=(hyou[ic1][ic2]+50)/2;
}
else {
kin=hyou[ic1][ic2]/2;
}
}
else {
kin=hyou[ic1][ic2];
}
printf("%d\n",kin);
}
return 0;
}
|
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int ceil(int n) {
return (n / 50 + (n % 50 > 0)) * 50;
}
int cost[][7]{
{0,300,500,600,700,1350,1650},
{0,0,350,450,600,1150,1500},
{0,0,0,250,400,1000,1350},
{0,0,0,0,250,850,1300},
{0,0,0,0,0,600,1150},
{0,0,0,0,0,0,500},
};
int dist[][7]{
{},
{6},
{13,7},
{18,12,5},
{23,17,10,5},
{43,37,30,25,20},
{58,52,45,40,35,15}
};
int main() {
int d;
while (scanf("%d", &d), d) {
int hd, md, a, ha, ma; scanf("%d%d%d%d%d", &hd, &md, &a, &ha, &ma);
d--; a--;
if (((1050 <= hd * 60 + md&&hd * 60 + md <= 1170) || (1050 <= ha * 60 + ma&&ha * 60 + ma <= 1170)) && dist[max(d, a)][min(d, a)] <= 40)
printf("%d\n", ceil(cost[min(d, a)][max(a, d)] / 2));
else printf("%d\n", cost[min(d, a)][max(a, d)]);
}
} |
#include <iostream>
#define rng(z) (1050 <= z && z <= 1170)
using namespace std;
int a, b, t1, t2, p, q;
int x[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() {
while (cin >> a, a) {
cin >> p >> q; t1 = p * 60 + q; a--;
cin >> b >> p >> q; t2 = p * 60 + q; b--;
if (a > b) swap(a, b);
int cost = x[a][b], dist = x[b][a];
if (dist <= 40 && (rng(t1) || rng(t2))) cost /= 2;
cost = (cost + 49) / 50 * 50;
cout << cost << endl;
}
} |
#include<iostream>
#include<algorithm>
using namespace std;
const int da[] = { 0,0,6,13,18,23,43,58 };
int f(int a, int b, bool c) {
int p;
if (a == 1 && b == 2)p = 300;
else if (a == 1 && b == 3)p = 500;
else if (a == 1 && b == 4)p = 600;
else if (a == 1 && b == 5)p = 700;
else if (a == 1 && b == 6)p = 1350;
else if (a == 1 && b == 7)p = 1650;
else if (a == 2 && b == 3)p = 350;
else if (a == 2 && b == 4)p = 450;
else if (a == 2 && b == 5)p = 600;
else if (a == 2 && b == 6)p = 1150;
else if (a == 2 && b == 7)p = 1500;
else if (a == 3 && b == 4)p = 250;
else if (a == 3 && b == 5)p = 400;
else if (a == 3 && b == 6)p = 1000;
else if (a == 3 && b == 7)p = 1350;
else if (a == 4 && b == 5)p = 250;
else if (a == 4 && b == 6)p = 850;
else if (a == 4 && b == 7)p = 1300;
else if (a == 5 && b == 6)p = 600;
else if (a == 5 && b == 7)p = 1150;
else if (a == 6 && b == 7)p = 500;
else p = 114514;
if (c)p /= 2;
if (p % 50 != 0)p += 25;
return p;
}
int main() {
int a, b, c, d;
while (cin >> a, a) {
int h, w; cin >> h >> w;
b = h * 100 + w;
cin >> c;
cin >> h >> w;
d = h * 100 + w;
int dis = da[max(a, c)] - da[min(a, c)];
bool e;
if (((1730 <= b && b <= 1930) || (1730 <= d && d <= 1930)) && dis <= 40)e = true; else e = false;
cout << f(min(a, c), max(a, c), e) << endl;
}
} |
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
using namespace std;
#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
bool intime(int n)
{
return 1730<=n && n<=1930;
}
pii getinfo(int src,int dst)
{
int table[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},
};
src--;dst--;
if(src>dst) swap(src,dst);
return mp(table[dst][src],table[src][dst]);
}
int main()
{
for(int n1,h1,m1,n2,h2,m2;cin>>n1,n1;){
cin>>h1>>m1>>n2>>h2>>m2;
int t1=h1*100+m1,t2=h2*100+m2;
pii info=getinfo(n1,n2);
bool harf=(intime(t1)||intime(t2))&&info.first<=40;
if(harf){
info.second/=2;
info.second=(info.second+49)/50*50;
}
cout<<info.second<<endl;
}
return 0;
} |
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;
template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;
int main() {
int v[7][7]={{-1,300,500,600,700,1350,1650},
{6,-1,350,450,600,1150,1500},
{13,7,-1,250,400,1000,1350},
{18,12,5,-1,250,850,1300},
{23,17,10,5,-1,600,1150},
{43,37,30,25,20,-1,500},
{58,52,45,40,35,15}};
int a;
while(cin >> a, a){
int h1, m1, b, h2, m2;
cin >> h1 >> m1 >> b >> h2 >> m2;
a--; b--;
if(a > b) swap(a, b);
int p = h1*60+m1, q = h2*60+m2;
if(v[b][a] <= 40 && ((1050 <= p && p <= 1170) || (1050 <= q && q <= 1170))){
cout << (v[a][b]/2+49)/50*50 << "\n";
}else {
cout << v[a][b] << "\n";
}
}
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.