惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
MyScale Blog
MyScale Blog
博客园 - Franky
The Cloudflare Blog
IT之家
IT之家
Blog — PlanetScale
Blog — PlanetScale
博客园 - 聂微东
WordPress大学
WordPress大学
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
The Blog of Author Tim Ferriss
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
罗磊的独立博客
Google DeepMind News
Google DeepMind News
P
Proofpoint News Feed
Martin Fowler
Martin Fowler
aimingoo的专栏
aimingoo的专栏
J
Java Code Geeks
腾讯CDC
雷峰网
雷峰网
Microsoft Azure Blog
Microsoft Azure Blog
G
Google Developers Blog
博客园 - 【当耐特】
美团技术团队
云风的 BLOG
云风的 BLOG

OhYee 博客

小鹏辅助驾驶测评|OhYee 博客 小鹏非支持手机开启自动解锁|OhYee 博客 使用函数计算实现 301 重定向|OhYee 博客 针对 HTML 内容使用 Ant Design 图片弹框|OhYee 博客 博客进程泄露及僵尸进程解决|OhYee 博客 蓝易云服务器体验|OhYee 博客 SSH 调起本地 VSCode|OhYee 博客 【2022 秋招内推】阿里云后端研发工程师|OhYee 博客 使用函数计算获取 IP 地址信息|OhYee 博客 正确获取客户端 IP/HTTP Header 也可能重复|OhYee 博客 评测 Oculus Quest2 及 BigScreen|OhYee 博客 NextJS 热重载保留状态|OhYee 博客 如何优雅地贴 gist 代码|OhYee 博客 Linux 精细化文件权限|OhYee 博客 VSCode 容器开发环境|OhYee 博客 Clash 的不兼容更新排查|OhYee 博客 Zeek 导出 PCAP|OhYee 博客 记一次 ssh 配置问题|OhYee 博客 Git Commit 规范化工具|OhYee 博客 谈谈《星之卡比-探索发现》|OhYee 博客 VSCode 快捷键绑定 Shell 命令|OhYee 博客 ASN.1 语法及 X.509 证书格式解析解析|OhYee 博客 腾讯企业邮箱忽略 MX 记录发信|OhYee 博客 Chrome/Edge 标签组插件|OhYee 博客 【应届内推】阿里云后端研发工程师|OhYee 博客 损坏的 Typecho 备份处理为 JSON|OhYee 博客 VS Code VIM 插件高效使用|OhYee 博客 SSH 正反向代理|OhYee 博客 Let's Encrypt 根证书过期引发的问题|OhYee 博客 OpenWRT 忽略内核依赖|OhYee 博客
AOJ 836.周末大法好|OhYee 博客
2017-03-19 · via OhYee 博客

这是一篇最后编辑于 8 年前 的文章,其内容可能与目前实际情况差异较大,请注意甄别

题目

{% raw %}

{% endraw %} 在火星上,每年有x天。惊奇的是,和地球上一样,火星上也是有星期的概念的,连续的5天工作日,然后连续的2天周末。他们只有周末放假。 现在你的任务是,确定火星上每年可能的最少放假的天数和最多放假的天数。

{% raw %}


{% endraw %}

第一行,一个数字n。代表测试数据数量。
接下来n行,每行一个整数x (1<=x<=1,000,000),代表火星每年有x天。

{% raw %}


{% endraw %}

输出n行,每行两个整数。代表火星上每年可能的最少放假的天数和最多放假的天数。

{% raw %}




{% endraw %}

2
14
2

{% raw %}


{% endraw %}

4 4
0 2

{% raw %}




{% endraw %}

题解

纯模拟即可
想要假期最多,这一年就从周六开始
想要假期最少,这一年就从周一开始

先除以 7 算出一定要过的整星期
然后乘上 2 这是必然要过的假期

在对 7 取余数
对于最小值,多于 5 的话,就能过上下周的假期了
对于最大值, 2 天以内,多一天赚一天

代码

```cpp 周末大法好 https://github.com/OhYee/sourcecode/tree/master/ACM 代码备份 /*/ #define debug #include

//*/ #include #include #include #include #include using namespace std;

int main(){
#ifdef debug
freopen("in.txt", "r", stdin);
int START = clock();
#endif
cin.tie(0);
cin.sync_with_stdio(false);

int T;
cin >> T;
while(T--){
    int n;
    cin >> n;
    int mod = n % 7;

    int Min = 2 * (n / 7);
    if(mod > 5)
        Min += mod - 5;

    int Max = 2 * (n / 7) + min(mod,2);

    cout << Min << " " << Max << endl;
}

#ifdef debug
printf("Time:%.3fs.\n", double(clock() - START) / CLOCKS_PER_SEC);
#endif
return 0;

}

</div>