问题 A: Too Expensive to Buy a House
时间限制: 1 Sec 内存限制: 128 MB

题目描述
WNJXYK and DIDIDI are good friends . One day, WNJXYK found DIDIDI bought a house, so he also wanted to buy a house. Because the price of house is rising continuously, so WNJXYK hope that he can buy a house before he couldn’t afford it. Currently, a house need $A, the price increases by $B per mouth, and WNJXYK only have a deposit of $C. Your assignment is to calculate in how many months should WNJXYK buy the house before he couldn’t afford it.

输入
The first line of input contains a positive integer T telling you there are T test cases followed.
Each test case will contain 3 integers, A, B, C.
输出
For each test case, print a line “Case #x: y”, where x is the case number (starting from 1) and y is an integer indicating the number of months.

样例输入
3
1 2 3
1 2 6
1 2 1
样例输出
Case #1: 1
Case #2: 2
Case #3: 0

提示
Tips:1≤T≤20,1≤A≤C≤1e9, 1≤B≤1e6
Case 1: after 1 month, price will be 3
Case 2: after 2 months, price will be 5, after 3 months, price will be 7, and he can’t afford it.
Case 3: after 1 month, price will be 3, he can’t afford it.

这题直接看题目就行了,数据都不需要看,题意:某人想买房子,房子的基本价格为A,每个月还会上涨B,某人有C元,问最多能到第几个月还能买得起。就是一个整除问题,公式:(C-A)/B。时间复杂度几近O(1),直接暴力即可。

#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll t,a,b,c,ans;int main()
{cin>>t;for(int i=1; i<=t; i++){cin>>a>>b>>c;ans = (c-a)/b;printf("Case #%d: %d\n", i, ans);}return 0;
}

问题 B: WNJXYK loves to take a shower
时间限制: 1 Sec 内存限制: 128 MB

题目描述
WNJXYK often takes a shower in school public bathroom. The bathroom has many cabinets. WNJXYK found that the number of the cabinet is strange. No number contains digit ‘4’, in other words, numbers like ‘14’,’34’,’456’ don’t exist. So cabinet 5 is actually the 4th cabinet. We know WNJXYK’s number is N. Your assignment is to calculate his cabinet’s real number.

输入
The first line of input contains a positive integer T telling you there are T test cases followed.
Each test case will contain one integer.
输出
For each test case, print a line “Case #x: y”, where x is the case number (starting from 1) and y is an integer indicating real number of WNJXYK’s cabinet.

样例输入
2
5
15
样例输出
Case #1: 4
Case #2: 13

提示
Tips:1≤T≤20,1≤N≤10000
Case 1: 1 2 3 5
Csse 2: 1 2 3 5 6 7 8 9 10 11 12 13 15

多组数据,每组输出n减去1~n中含有4的数字的数目。重点操作:sprintf(str,“%d”, i)—— 数字转字符串

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int t,n,a[10010];bool f(int i)  //判断1~n中的某个数转化为字符后,是否含有4
{char s[8];  //因为n<=10000,所以开8位足够了 sprintf(s,"%d",i);  //某个数转化为字符for(int i=0; i<strlen(s); i++)if(s[i]=='4')  return false;  //有4则没number return true;
}int main()
{//可以事先进行预处理,降低复杂度 int cnt = 0; for(int i=1; i<=10000; i++){if(f(i))  cnt++;a[i] = cnt;}cin>>t; for(int i=1; i<=t ;i++){cin>>n;printf("Case #%d: %d\n",i,a[n]);}return 0;
}

问题 E: shovel snow
时间限制: 1 Sec 内存限制: 128 MB

题目描述
Northeast China snows every year, so school asks freshmen to shovel snow. This tradition lasts for many years. This year WNJXYK becomes the principle, he thinks that asking freshmen to shovel snow every year is boring, so he hopes that the grade who shovel snow can be different every year. The number of the grades is N, in order to illustrate, we assume N=5 here. WNJXYK hopes that in every 5-year, grade 1 shovels snow in the first year, grade 2 the second year, grade 3 the third year, and so on. We can use a permutation 12345 to express it. But in this circumstance DIDIDI find a problem that the grade 1 in the first year is exactly the grade 2 in the second year, so this grade shovels snow for many times in fact.
So DIDIDI use a permutation 13524, that is, first year - grade 1, second year – grade 3, third year – grade 5, fourth year – grade 2, fifth year – grade 4. In this case, every grade need to shovel snow exactly once. In more detail, we assume the first year is 2015. The grade 1 in first year is The Class of 2015. The grade 3 in second year is The Class of 2014. The grade 5 in third year is The Class of 2013. The grade 2 in forth year is The Class of 2017. The grade 4 in fifth year is The Class of 2016. So every grade need to shovel snow exactly once.
For every N given, you need to give a permutation with length N, which can satisfy the requirement that every grade shovels snow exactly once. If there are multiple answers, please give the one with the largest lexicographical order.

输入
The first line of input contains a positive integer T telling you there are T test cases followed.
Each test case will contain one integer N .
输出
For each test case, print two lines.
The first line is “Case #x:”, where x is the case number (starting from 1)。
The second line contains n integers, indicating a n-permutation. If threr is no answer, print “-1”.

样例输入
1
3
样例输出
Case #1:
3 2 1

提示
Tips:1≤T≤20,1≤N≤10000
Case 1: we assume the first year is 2015. The grade 3 in first year is The Class of 2013. The grade 2 in second year is The Class of 2015. The grade 1 in third year is The Class of 2017. The grade 3 in fourth year is The Class of 2016. The grade 2 in fifth year is The Class of 2018. The grade 1 in sixth year is The Class of 2020. The grade 3 in seventh year is The Class of 2019. And so on.

找规律…奇偶数对应相应的输出。

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 10010;
int t,n;int main()
{cin>>t;for(int i=1; i<=t; i++){cin>>n;printf("Case #%d:\n", i);if(!(n%2))  cout<<"-1"<<endl;else {for(int i=n; i>1; i--)  cout<<i<<" ";cout<<"1"<<endl;}}return 0;
}

UPC 2020年秋季组队训练赛第十四场相关推荐

  1. 【DFS反向建图记忆化搜索】UPC Contest2592 - 2020年秋季组队训练赛第十四场 问题 D: Mysterious Treasure

    问题 D: Mysterious Treasure 时间限制: 1 Sec 内存限制: 128 MB 题目描述 WNJXYK and DIDIDI is playing a game. DIDIDI ...

  2. 【upc】2020年秋季组队训练赛第十四场 Get Strong | 折半搜索、二分

    题目描述 WNJXYK and DIDIDI are friends. They are thinking about getting strong all the time. They are pl ...

  3. 【upc】2020年秋季组队训练赛第十二场J Greedy Termite | 删点线段树

    状态 题目描述 There are n wooden rods vertically placed over a horizontal line. The rods are numbered 1 th ...

  4. 石油大--2020年秋季组队训练赛第十二场----J、Greedy Termite(线段树)

    题面: 题意: 给定正整数 nnn 和起始位置 sss. nnn 表示有 nnn 个杆子,每个杆子由属性 (xi,hi)(x_i,h_i)(xi​,hi​) 构成,表示在 xix_ixi​ 处有一根高 ...

  5. 石油大--2020年秋季组队训练赛第十二场---- L、The Assembly Code(模拟)

    题面: 题意: 就是题目有点长,写起来直接写就好啦. 有一个长度为 232,0≤i<2322^{32},0\le i <2^{32}232,0≤i<232 数组 MMM , MiM_ ...

  6. 石油大--2020年秋季组队训练赛第十三场----B、Bouldering(最短路)

    题面: 题意: 给定一个 h∗wh*wh∗w 点阵,其中某一些点是可以走的. 这些点都有一个权值,表示如果经过当前点,则会花费的力气. 给定一个 rrr,你只能从当前点到达与你欧几里得距离不超过 rr ...

  7. 石油大--Contest2022 - 2020年秋季组队训练赛第二场--17100 Problem D、Find String in a Grid (AC自动机)

    题面: 题意: 给定一个 R∗CR*CR∗C 的字符矩阵,由大写字母构成. 有 qqq 个询问,每次给定一个由大写字母构成的字符串,问这个字符串在这个字符矩阵中出现了多少次. 某个字符串在矩阵中出现定 ...

  8. 石油大--2020年秋季组队训练赛第十三场---- C、Colourful Chameleons(思维)

    题面: 题意: 有 nnn 种颜色的变色龙,其中第 iii 种颜色的变色龙有 ai,(ai>=n−1)a_i ,(a_i>=n-1)ai​,(ai​>=n−1) 只. 我每次可以选择 ...

  9. UPC个人训练赛第十五场(AtCoder Grand Contest 031)

    传送门: [1]:AtCoder [2]:UPC比赛场 [3]:UPC补题场 参考资料 [1]:https://www.cnblogs.com/QLU-ACM/p/11191644.html B.Re ...

最新文章

  1. navicat保存查询语句_MySQL数据库安装创建及Navicat客户端连接
  2. 37. Sudoku Solver
  3. 阿帕奇退出java_java+tomcat+apache安装整合,启动/关闭,添加开机启动服务
  4. c语言树写入文件,如何安全地实现文件树遍历(C语言)
  5. leetcode714. 买卖股票的最佳时机含手续费(动态规划)
  6. Python之数据加密与解密(hashlib、hmac、random、base64、pycrypto)--转载
  7. Dubbo的负载均衡、集群容错、服务降级等机制详解
  8. java后端通过Filter过滤器解决跨域问题
  9. 蓝桥杯 ALGO-47 算法训练 蜜蜂飞舞
  10. 4——编码规则以及vim的使用和虚拟环境
  11. 两年后,中国CF又站在了世界之巅
  12. 【PC工具】PC好用的迅雷下载版本合集,hash资源下载方法,石皮版迅雷软件去广告优化增强典藏版...
  13. 深入理解Android相机体系结构之八
  14. 为大家推荐几个不错的公众号!
  15. 其他-IMU与AHRS区别
  16. FluentAPI 学习
  17. js点击下载文件的几种情况
  18. 源于日本的工作之道“守破离”是个学习路径的好方法
  19. 身份证件识别接口编写的JAVA调用示例
  20. 手把手教你使用Python网络爬虫获取B站视频选集内容(附源码)

热门文章

  1. 2018华为校招机试题目
  2. 小学四年级计算机制作月历教案,【信息技术】《 制作月历》第一次教学设计——林爱芳...
  3. 机房考试是用计算机考试吗,计算机考试,你挂了吗?
  4. XML、XML Schema及XSL的应用——信息组织实验报告
  5. 基本服务器的AAA实验(Cisco PT)
  6. js小孩翻书动态实现效果
  7. Potato家族本地提权分析
  8. Android 打开PDF,PPT等类型的文件方式
  9. FPGA零基础学习:IP CORE 之 FIFO设计
  10. 数据结构(主席树):COGS 2211. 谈笑风生