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

zoj 3854 Travel by Bike

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

zoj 3854 Travel by Bike

#include<cstdio>#include<cstdlib>#include<iostream>#include<cstring>#include<map>#include<set>#include<list>#include<stack>#include<algorithm>#include<queue>#include<vector>#include<time.h>#include<iomanip>#include<assert.h>using namespace std;typedef long long ll;map<string,int> days;string dn[8] = {"","Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};string st;int L;char Line[10000];ll speed;ll Length;void scan(){    st = "";    Length = 0;    int pre = 0;    int rear = 0;    int len = strlen(Line);    int i = 0;    for(i = 0;;++i){        if(Line[i] == ' '){i++;break;}        st += Line[i];    }    for(;;++i){        if(Line[i] == ' '){i++;break;}        Length = Length *10+Line[i]-'0';    }    Length *=1000;    for(;i<len; ++i){        if(Line[i] =='.'){i++;break;}        pre = pre*10 + Line[i] - '0';    }    for(;i<len;++i){        rear = rear *10 + Line[i] - '0';    }    speed = pre*1000+rear;}int main(){    days["Monday"] = 1;days["Tuesday"] = 2;days["Wednesday"] = 3;days["Thursday"] = 4;    days["Friday"] = 5;days["Saturday"] = 6;days["Sunday"] = 7;    while(cin.getline(Line,1000)){        if(strlen(Line) == 0)break;        scan();        int start = days[st];        ll weekday = speed*8; ll weekend = speed*4;        ll oneweek = weekday*5+weekend *2;        ll remain = Length % oneweek;        while(remain>0){ if(start == 8)start = 1; if(start <=5)remain -= weekday; else remain -= weekend; start ++;if(start == 8)start = 1;        }        start --;if(start == 0)start = 7;        cout<<dn[start]<<endl;    }    return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/380623.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

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

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