A 计划日

题意:已知李明在YYYY年MM月DD日星期W订了学习计划,现在想看看李明N天后的完成情况和个人总结,你能告诉我那天的日期和星期几吗?

模拟日期计算;

计算星期可以用基姆拉尔森公式

//中国的星期 结果要+1
int Day(int y,int m,int d)
{
if(m==1 || m==2) m+=12,y-=1;
return (d+2*m+3*(m+1)/5+y+y/4-y/100+y/400+1)%7;
}

AC代码

#include<bits/stdc++.h>
using namespace std; int t;
bool isLeap(int year){
if(year %4 == 0 && year%100!=0 || year%400== 0){
return true;
}
return false;
} int main(){
cin>>t;
while(t--){
int year,ta,tb,tc,td,w,n,month,day;
scanf("%4d%1d%1d%1d%1d %d %d",&year,&ta,&tb,&tc,&td,&w,&n);
month = ta*10 + tb;
day = tc*10 + td;
if(w==7) w=0; for(int i=1;i<=n;i++){
if(month == 12){
if(day==31){
year++;
month = 1;
day = 1;
}else{
day++;
}
}else if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10){
if(day == 31){
month++;
day = 1;
}else{
day++;
}
}else if(month == 4 || month == 6 || month == 9 || month == 11){
if(day == 30){
month++;
day = 1;
}else{
day++;
}
}else if(month == 2){
if(isLeap(year)){
if(day == 29){
month++;
day = 1;
}else{
day++;
}
}else{
if(day == 28){
month++;
day = 1;
}else{
day++;
}
}
}
w = (w+1)%7;
}
printf("%d",year);
if(month<10){
printf("0%d",month);
}else{
printf("%d",month);
}
if(day<10){
printf("0%d ",day);
}else{
printf("%d ",day);
}
if(w==0) w = 7;
printf("%d\n",w); }
return 0;
}

B 治安管理

题意:YYH大型活动将在[S,F)这段时间举行,现要求活动期间任何时刻巡逻的警察人数不少于M人。公安机关将有N名警察在维护活动的安全,每人巡逻时间为[ai,bi)。请你检查目前的值班安排,是否符合要求。若满足要求,输出YES,并输出某个时刻同时巡逻的最多人数;若不满足要求,输出NO,并输出某个时刻同时巡逻的最少人数。

暴力可以过;数据如果再复杂点,可以用差分求解区间问题。

AC代码

#include<bits/stdc++.h>
using namespace std; int t;
const int maxn = 1e6+5;
int n,m,s,f;
int p[maxn];
int q[maxn];
int a[maxn]; int main(){
cin>>t;
while(t--){
memset(a,0,sizeof(a));
memset(p,0,sizeof(p));
memset(q,0,sizeof(q));
cin>>n>>m>>s>>f;
for(int i=1;i<=n;i++) cin>>p[i];
for(int i=1;i<=n;i++) cin>>q[i];
for(int i=1;i<=n;i++){
for(int j=p[i];j<q[i];j++){
a[j]++;
}
}
int mint = 0x3f3f3f3f;
int maxt = 0;
for(int i=s;i<f;i++){
if(mint >= a[i]) mint = a[i];
if(maxt <= a[i]) maxt = a[i];
}
if(mint == 0x3f3f3f3f) mint = 0;
if(mint<m)cout<<"NO "<<mint<<endl;
else cout<<"YES "<<maxt<<endl;
}
return 0;
}

C 山区修路

最近,HB省决定修一条从YC市通往SNJ风景区的高速公路。经过勘测分析,途中需要经过高度分别为H1,H2,……,Hn的N个山区。由于高低不平,除正常的修路开支外,每段还要多出高度差|Hi - Hi-1|*X万元的斜坡费用。Dr. Kong 决定通过填高一些区域的高度来降低总的费用。当然填高也是需要一些费用的。每填高Y单位,需要付出Y2万元费用。

你能否帮Dr. Kong做出一个规划,通过部分填高工程改造,使得总的费用降下来。

思路:线性dp,开始想用一维dp,发现一维没法做啊,前后两个山区都影响当前状态。应该用二维dp[i][j] 表示第i个山区在高度为j时的最小费用。

D 求XF+闭包

题意:前面大段都不用看

已知 F 是关系模式R(U)上的函数依赖集,利用Armstrong公理系统可以推导出更多的函数依赖。设X是属性集U={ A1,A2, ……, An} 的子集, 定义X关于F的闭包XF+

XF+={ Ai | 若X->Ai可以通过Armstrong公理导出}

对于给定的U , F ,X, 请求出XF+

意思就是:若X包含S,就将T加入X

思路:我是用字符串string直接做的,string.find()来查找

AC代码,南阳oj过不了,郑轻可以过,有时间再补题吧

#include<bits/stdc++.h>
using namespace std; int t;
set<char> se; int main(){
cin>>t;
while(t--){
int n,m,k;
cin>>n>>m>>k;
string u,x;
cin>>u;
cin>>x;
for(int i=1;i<=k;i++){
string s;
string t;
cin>>s;
cin>>t;
bool flag = true;
int len = s.length();
for(int j=0;j<len;j++){
if(x.find(s[j]) == string::npos){
flag = false;
break;
}
}
int len2 = t.length();
if(flag){
x.insert(x.length(),t);
// cout<<x<<endl;
}
}
for(int i=0;i<x.length();i++){
se.insert(x[i]);
}
set<char>::iterator it = se.begin();
while(it!=se.end()){
cout<<*it;
it++;
}
cout<<endl;
se.clear();
}
return 0;
}

E 物流配送

http://nyoj.top/web/contest/problem/cid/103/num/E

听说是最小费用最大流

但是我没做过题,想学的时候再补。

F Gene mutation

http://nyoj.top/web/contest/problem/cid/103/num/F

一道简单英文题

思路1:从X数组出发 枚举起点,看看x[i] - y[1]的长度下,x数组中是否都包含Y[j] + x[i] - y[1]

思路2:从Y数组出发,枚举加减的数量,在X中查找,如果存在Y的每一个元素,则记为一种方案。

我用思路2做的没过,有时间再用思路1做

G Checkpoints

Chinese peacekeepers are going to the town of Kerver to seek Chinese foreign aid engineers.

The military map shows that there are many checkpoints in the war zone. It can be modeled as a directed graph: nodes represent checkpoints , and edges represents the roads. The goal is that the less peacekeepers pass the checkpoints, the safer it will be.

做ACM的英文题,前几段落都可以不读,题意重点在最后两段。。

这题是求单源点最短路

用dijkstra跑一遍

南阳OJ过不了,郑轻可以AC。。。有时间再查问题

#include<bits/stdc++.h>
using namespace std; int t;
int A,B;
const int MAX_N = 105;
const int MAX_M = 100000;
const int inf = 0x3f3f3f3f;
struct edge {
int v, w, next;
} e[MAX_M];
int p[MAX_N], eid, n,m;
void mapinit() {
memset(p, -1, sizeof(p));
eid = 0;
}
void insert(int u, int v, int w) { // 插入带权有向边
e[eid].v = v;
e[eid].w = w;
e[eid].next = p[u];
p[u] = eid++;
}
void insert2(int u, int v, int w) { // 插入带权双向边
insert(u, v, w);
insert(v, u, w);
}
int dist[MAX_N]; // 存储单源最短路的结果
bool vst[MAX_N]; // 标记每个顶点是否在集合 U 中
struct node {
int u;
int dist;
node(int _u, int _dist) : u(_u), dist(_dist) {}
bool operator < (const node &x) const {
return dist > x.dist;
}
}; // 记录点的结构体
bool dijkstra(int s) {
// 初始化 dist、小根堆和集合 U
memset(vst, 0, sizeof(vst));
memset(dist, 0x3f, sizeof(dist));
priority_queue<node> min_heap;
dist[s] = 0;
min_heap.push(node(s, 0));
while (!min_heap.empty()){
// 获取堆顶元素,并将堆顶元素从堆中删除
int v = min_heap.top().u;
min_heap.pop();
if (vst[v]) {
continue;
}
vst[v] = true;
// 进行和普通 dijkstra 算法类似的松弛操作
for (int j = p[v]; j != -1; j = e[j].next) {
int x = e[j].v;
if (!vst[x] && dist[v] + e[j].w < dist[x]) {
dist[x] = dist[v] + e[j].w;
min_heap.push(node(x, dist[x]));
}
}
}
return true;
} int main(){
cin>>t;
while(t--){
cin>>n>>m>>A>>B;
mapinit();
for(int i=1;i<=m;i++){
int u,v;
cin>>u>>v;
insert(u,v,1);
}
dijkstra(A);
cout<<dist[B]<<endl;
}
return 0;
}

H Attack City and Capture Territory

Who breaks through the last firepower point, he will win the city.

Because of limited weaponry, weapons of each side can only attack one firepower at a time. But they can control whether completely destroy this firepower point or weaken the strength of firepower point.

Liu_B has a strong think-tank. After calculation, he finds out who will attack first , who will more likely win the city .

从最后两段中理解题意,是一个直接的nim博弈。

AC代码

#include<bits/stdc++.h>
using namespace std; int t;
int a[1010];
int n; int main(){
cin>>t;
while(t--){
cin>>n;
for(int i=1;i<=n;i++) cin>>a[i];
int res = 0;
for(int i=1;i<=n;i++) res^=a[i];
if(res){
puts("Liu_B is sure to win.");
}else{
puts("Liu_B is not sure to win.");
}
}
return 0;
}

每天一套题打卡|河南省第十一届ACM/ICPC的更多相关文章

  1. 每天一套题打卡|河南省第九届ACM/ICPC

    A 表达式求值 表达式求值:可以用递归求解,也可以用栈模拟,考过多次. 类似题目:NYOJ305,NYOJ35 用栈模拟做法: #include <stdio.h> #include &l ...

  2. 每天一套题打卡|河南省第十届ACM/ICPC

    A.谍报分析 题意:请你编程,快速统计出频率高的前十个单词. 思路:字符串输入,map哈希表map<string,int >记录每个单词出现的次数,pair重载优先级 #include&l ...

  3. 每天一套题打卡|河南省第七届ACM/ICPC

    A 海岛争霸 题目:Q次询问,他想知道从岛屿A 到岛屿B 有没有行驶航线,若有的话,所经过的航线,危险程度最小可能是多少. 多源点最短路,用floyd 在松弛更新:g[i][k] < g[i][ ...

  4. 每天一套题打卡|河南省第八届ACM/ICPC

    A 挑战密室 化学方程式求分子量 这题我懒得写了 可以用map<string,int>哈希表,表示每种分子的相对分子质量 之后,从头遍历到尾. 1.数字:连读直到不是数字 2.字母:连读直 ...

  5. 河南省第十一届ACM大学生程序设计竞赛

    nyoj-1365-山区修路 内存限制:128MB 时间限制:3000ms 特判: No通过数:4 提交数:4 难度:3 题目描述: SNJ位于HB省西部一片群峰耸立的高大山地,横亘于A江.B水之间, ...

  6. 递推水题 Codeforces Round #289 (Div. 2, ACM ICPC Rules) A. Maximum in Table

    题目传送门 /* 模拟递推水题 */ #include <cstdio> #include <iostream> #include <cmath> #include ...

  7. [水题日常]UVA1639 糖果(Candy,ACM/ICPC Chengdu 2012)

    今天来尝试了几道数学期望相关的题,这是我认为比较有趣的一道题 这次不废话啦直接开始~ 一句话题意:两个分别装有n个糖果的盒子,每次随机选一个盒子然后拿走一颗糖(选的概率分别是\(p\)和\((1-p) ...

  8. codeforces水题100道 第十八题 Codeforces Round #289 (Div. 2, ACM ICPC Rules) A. Maximum in Table (brute force)

    题目链接:http://www.codeforces.com/problemset/problem/509/A题意:f[i][1]=f[1][i]=1,f[i][j]=f[i-1][j]+f[i][j ...

  9. 【河南省第十一届ACM大学生程序设计竞赛-D】.求XF+闭包

       如何设计一个好的数据库不仅仅是一个理论研究问题,也是一个实际应用问题.在关系数据库中不满足规范化理论的数据库设计会存在冗余.插入异常.删除异常等现象. 设R(U)是一个关系模式,U={ A1,A ...

随机推荐

  1. 一、使用官方工具建立空springboot

          自己搭过springboot,看的官网,一点点自己弄,集成druid,做了些例子,从0到1弄了一下午. 当时没看到有工具可用,可以把依赖都加上,简称STS.       下载地址: htt ...

  2. Java-字符串、集合

    1.只要是字符串,必然是对象. 2.API文档的基本使用 3.如何创建字符串: 直接饮用赋值,也是一个字符串对象. 可以通过new关键字来调用string的构造方法: public string (c ...

  3. jedis & common pool

    http://mvnrepository.com/artifact/redis.clients/jedis http://mvnrepository.com/artifact/org.apache.c ...

  4. csrf jsonp

    网站b中包含向网站a发送的请求,那么网站b就会获得网站a的cookie,网站a登录了则网站b的cookie中会有网站a的sessionid,此时如果网站a对外提供需要sessionid的jsonp接口 ...

  5. AD、PADS、Cadence对比

    本人平时主要接触的是FPGA设计,最近找工作发现有些企业要求会画PCB电路,所以开始学习相关工具软件.主流软件是Altium Designer,PADS和Cadence这三个. 三大工具的用途: AD ...

  6. java实现控件的移动及使用鼠标改变控件大小

    package cn.com.test; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; ...

  7. Nginx配置不当可能导致的安全问题

    Nginx配置不当可能导致的安全问题 Auther: Spark1e目前很多网站使用了nginx或者tenginx(淘宝基于Nginx研发的web服务器)来做反向代理和静态服务器,ningx的配置文件 ...

  8. kali,parrot最新更新debain源

    deb http://mirrors.163.com/debian/ jessie main non-free contribdeb http://mirrors.163.com/debian/ je ...

  9. 551.学生出勤记录I

    /* * @lc app=leetcode.cn id=551 lang=java * * [551] 学生出勤记录 I * * https://leetcode-cn.com/problems/st ...

  10. 201901<<叶武滨时间管理100讲>>

    2019年1月份读物整理: 1月份,在喜马拉雅上听的这个课程叶武滨时间管理100讲,每天利用上下班时间听完的,对其中的一些讲的点很有感触.今年的读书计划,希望自己能把读的每本书都用思维导图的方式整理出 ...