Kattis - friday 【数学】
2024-09-05 14:46:57
题意
每一年的第一天 都是星期天
然后 给出 一年的总天数 和 总月数
以及 每个月 的总天数
求出 有多少个星期五 是当月的13号
思路
对于 每个月 只要判断 当月的13号 是不是 星期五 就可以了
那么 给出 一个 第几天 怎么判断 是星期几呢
因为 每年的第一天 都是星期天
所以 我们可以 依次 另 星期天 到 星期六 为 0-6
然后 给出第几天(tot) 我们 只要 用(tot - 1) % 7 来判断 就可以了
AC代码
#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <cstdlib>
#include <climits>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <limits>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const double PI = 3.14159265358979323846264338327;
const double E = exp(1);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int maxn = 1e3 + 5;
const int MOD = 1e9 + 7;
int main()
{
int t;
cin >> t;
while (t--)
{
int d, m;
scanf("%d%d", &d, &m);
int ans = 0;
int tot = 0;
for (int i = 0; i < m; i++)
{
scanf("%d", &d);
if ((tot + 12) % 7 == 5 && d >= 13)
ans++;
tot += d;
}
cout << ans << endl;
}
}
最新文章
- CSS浮动文摘
- eclipse左侧不见
- 在指定时间干,必须干(kbmmw 中的事件调度)
- openstack security group and rules python api use
- android Studio项目运行时报错“Could not identify launch activity: Default Activity not found”
- linux下如何优雅的挂载一个外界设备(比如优盘)
- Android中Service的使用详解和注意点(LocalService)
- hadoop配置优化
- poj3579 二分搜索+二分查找
- 能让汇编转到C51的初学者有更清晰的认识的一篇文章
- mongodb remove删除文档的用法
- 动手学习TCP:数据传输(转)
- wepy框架自定义组件编译报错not Found File XXX.wxss
- 关于getchar-scanf函数的相关坑!
- nginx 配置laravel框架域名配置
- 【云服务器部署】---Linux下安装nginx
- 初识Linux系统
- 指定nvm的默认版本号
- python numpy访问行列元素的方法
- ansible的安装过程 和基本使用