团体程序设计天梯赛-练习集

  1. /** @Description: 出生年* @version: * @Author: * @Date: 2021-03-25 08:13:57* @LastEditors: Please set LastEditors* @LastEditTime: 2021-03-25 08:25:50*/
    #include <iostream>
    #include <string>
    #include <set>
    using namespace std;
    string toString(int year)
    {// NOTE:数字转字符串string str = to_string(year);if (year < 10)str.insert(str.begin(), 3, '0');else if (year < 100)str.insert(str.begin(), 2, '0');else if (year < 1000)str.insert(str.begin(), 1, '0');return str;
    }
    int num(int year)
    {string str = toString(year);set<char> s(str.begin(), str.end());return s.size();
    }
    int main(void)
    {int y, n;cin >> y >> n;int i;for (i = 0;; i++){if (num(y + i) == n)break;}cout << i << " " << toString(y + i) << endl;system("pause");return 0;
    }
    
  2. /** @Description: 点赞* @version:* @Author:* @Date: 2021-03-25 08:28:32* @LastEditors: Please set LastEditors* @LastEditTime: 2021-03-25 09:23:37*/
    #include <map>
    #include <vector>
    #include <iostream>
    #include <algorithm>
    using namespace std;
    bool cmp(const pair<int, int> &a, const pair<int, int> &b)
    {if (a.second > b.second)return true;else if (a.second < b.second)return false;else if(a.second==b.second)return a.first > b.first;
    }
    int main(void)
    {int n;cin >> n;map<int, int> m;for (int i = 0; i < n; i++){int num, tag;cin >> num;for (int j = 0; j < num; j++){cin >> tag;if (m.find(tag) == m.end())m[tag] = 1;elsem[tag]++;}}// NOTE:map的自定义排序vector<pair<int, int>> v(m.begin(), m.end());sort(v.begin(), v.end(), cmp);cout << v.begin()->first << " " << v.begin()->second << endl;system("pause");return 0;
    }
    
  3. /** @Description: 情人节* @version: * @Author: * @Date: 2021-03-25 08:57:51* @LastEditors: Please set LastEditors* @LastEditTime: 2021-03-25 09:13:29*/
    #include <iostream>
    #include <string>
    using namespace std;
    int main(void)
    {string stra, strb;int i = 1;while (true){string str;getline(cin, str, '\n');if (str == "."){i--;break;}else if (i == 2)stra = str;else if (i == 14)strb = str;i++;}if (i < 2)cout << "Momo... No one is for you ..." << endl;else if (i < 14)cout << stra<< " is the only one for you..." << endl;elsecout << stra << " and " << strb << " are inviting you to dinner..."<<endl;system("pause");return 0;
    }
    
  4. /** @Description: A*B* @version: * @Author: * @Date: 2021-03-25 09:13:37* @LastEditors: Please set LastEditors* @LastEditTime: 2021-03-25 09:14:57*/
    #include <iostream>
    using namespace std;
    int main(void)
    {int a, b;cin >> a >> b;cout << a * b << endl;return 0;
    }
    
  5. /** @Description: A除B* @version: * @Author: * @Date: 2021-03-25 09:16:01* @LastEditors: Please set LastEditors* @LastEditTime: 2021-03-25 09:19:04*/
    #include <iostream>
    #include <stdio.h>
    using namespace std;
    int main(void)
    {int a, b;cin >> a >> b;if (b > 0)printf("%d/%d=%.2f\n", a, b, a * 1.0 / b);else if (b < 0)printf("%d/(%d)=%.2f\n", a, b, a * 1.0 / b);else if (b == 0)printf("%d/%d=Error\n", a, b);return 0;
    }
    
  6. /** @Description: 新世界* @version: * @Author: * @Date: 2021-03-25 09:19:58* @LastEditors: Please set LastEditors* @LastEditTime: 2021-03-25 09:20:54*/
    #include <iostream>
    using namespace std;
    int main(void)
    {cout << "Hello World\nHello New World" << endl;return 0;
    }
    
  7. /** @Description: 古风排版* @version: * @Author: * @Date: 2021-03-25 09:24:28* @LastEditors: Please set LastEditors* @LastEditTime: 2021-03-25 09:27:17*/
    // TODO:来源于网络
    #include <stdio.h>
    #include <string.h>
    int vis[1010][1101];
    int main()
    {int n;char s[1010];char s1[1010][1010];scanf("%d", &n);getchar();gets(s);int l = strlen(s);memset(vis, 0, sizeof(vis));int l2 = 0;int i = 0;int p;if (l % n == 0){p = l / n;}elsep = l / n + 1;int ni = 0;while (l2 < p){int l1 = 0;for (i = i; i < l; i++){if (l1 >= n){break;}if (i >= l){ni = 1;break;}else{s1[l1][l2] = s[i];vis[l1][l2] = 1;l1++;}}if (ni == 1)break;l2++;}for (int i = 0; i < n; i++){for (int j = p - 1; j >= 0; j--){if (vis[i][j] == 1)printf("%c", s1[i][j]);elseprintf(" ");}printf("\n");}
    }
    
  8. /** @Description: 最佳情侣身高差* @version: * @Author: * @Date: 2021-03-25 09:28:29* @LastEditors: Please set LastEditors* @LastEditTime: 2021-03-25 09:39:51*/
    #include <iostream>
    #include <stdio.h>
    using namespace std;
    int main(void)
    {int n;cin >> n;for (int i = 0; i < n; i++){char gender;float height;cin >> gender >> height;if (gender == 'M')printf("%.2f\n", height / 1.09);else if(gender == 'F')printf("%.2f\n", height * 1.09);}return 0;
    }
    
  9. /** @Description: 寻找250* @version: * @Author: * @Date: 2021-03-25 18:43:33* @LastEditors: Please set LastEditors* @LastEditTime: 2021-03-25 20:46:16*/
    #include <iostream>
    #include <string>
    #include <ctype.h>
    using namespace std;
    int main(void)
    {string str;getline(cin, str, '\n');int count = 1;int n = str.find("250", 0);while (true){// NOTE:需满足以下条件,250字符串后为空格,若不是字符串首,前面也应该是空格,不满足任一条件即重新从下一位置查找if ((n != 0 && str[n - 1] != ' ') || str[n + 3] != ' ')n = str.find("250", n + 1);if (n == 0)break;elsebreak;}for (int i = 0; i < n; i++){// NOTE:防止数字间的多个空格,所以限制空格后面是数字或-才计数if (str[i] == ' ' && (isdigit(str[i + 1]) || str[i + 1] == '-'))count++;}cout << count << endl;system("pause");return 0;
    }
    
  10. /** @Description: 日期格式化* @version: * @Author: * @Date: 2021-03-25 20:46:30* @LastEditors: Please set LastEditors* @LastEditTime: 2021-03-25 20:51:11*/
    #include <iostream>
    #include <stdio.h>
    using namespace std;
    int main(void)
    {int year, month, day;scanf("%d-%d-%d", &month, &day, &year);printf("%04d-%02d-%02d\n", year, month, day);system("pause");return 0;
    }
    
  11. /** @Description: 阅览室* @version: * @Author: * @Date: 2021-03-25 20:56:57* @LastEditors: Please set LastEditors* @LastEditTime: 2021-03-25 21:39:43*/
    #include <iostream>
    #include <map>
    #include <stdio.h>
    #include <math.h>
    using namespace std;
    int main(void)
    {map<int, int> m;int n, count = 0;cin >> n;int num_person = 0, time = 0;while (true){if (count == n)break;int id, hour, minute;char ch;scanf("%d %c %d:%d", &id, &ch, &hour, &minute);if (id == 0){count++;num_person -= m.size();if (!num_person)cout << 0 << " " << 0 << endl;elsecout << num_person << " " << (int)round(1.0 * time / num_person) << endl;num_person = 0, time = 0;m.erase(m.begin(), m.end());continue;}if (m.find(id) == m.end() && ch == 'E')continue;if (ch == 'S'){if (m.find(id) != m.end()){m.erase(id);num_person--;}m[id] = hour * 60 + minute;num_person++;}else if (ch == 'E'){time += (hour * 60 + minute - m[id]);m.erase(id);}}system("pause");return 0;
    }
    
  12. /** @Description: * @version: * @Author: * @Date: 2021-03-25 21:40:12* @LastEditors: Please set LastEditors* @LastEditTime: 2021-03-25 21:47:20*/
    #include <string>
    #include <iostream>
    #include <map>
    using namespace std;
    int main(void)
    {int n;cin >> n;map<string, string> m;m["JianDao"] = "Chuizi";m["Bu"] = "JianDao";m["ChuiZi"] = "Bu";for (int i = 1;; i++){string str;cin >> str;if (str == "End")break;if (i % (n + 1) == 0){cout << str << endl;continue;}else{cout << m[str] << endl;}}return 0;
    }
    
  13. /** @Description: * @version: * @Author: * @Date: 2021-03-25 21:53:19* @LastEditors: Please set LastEditors* @LastEditTime: 2021-03-25 21:54:27*/
    #include <iostream>
    #include <string>
    using namespace std;
    int main(void)
    {string str;cin >> str;cout << "Hello " << str << endl;system("pause");return 0;
    }
    
  14. /** @Description: 光棍数* @version: * @Author: * @Date: 2021-03-25 22:05:24* @LastEditors: Please set LastEditors* @LastEditTime: 2021-03-25 22:30:43*/
    // TODO:来源于网络
    #include <cstdio>
    using namespace std;
    int main()
    {int n;scanf("%d", &n);int cnt = 0, tmp = n, k = 1; //k一直充当被除数的作用while (tmp)                  //该数本身的位数{++cnt;k = k * 10 + 1;tmp /= 10;}if (n == k / 10) //本身就是光棍数,不适合这样.11之后k变成了111;12应该从111开始模拟除法{printf("1 %d\n", cnt);return 0;}while (k != 1){++cnt; //另补1的个数printf("%d", k / n);k -= k / n * n; //余数k = k * 10 + 1; //新的被除数}printf(" %d\n", cnt);
    }
  15. /** @Description: 装睡* @version: * @Author: * @Date: 2021-03-25 22:29:20* @LastEditors: Please set LastEditors* @LastEditTime: 2021-03-25 22:34:26*/
    #include <iostream>
    #include <string>
    using namespace std;
    int main(void)
    {int n;cin >> n;for (int i = 0; i < n; i++){string str;int a, b;cin >> str >> a >> b;if (a >= 15 && a <= 20 && b >= 50 && b <= 70)continue;elsecout << str << endl;}system("pause");return 0;
    }
    
  16. /** @Description: 矩阵A乘B* @version: * @Author: * @Date: 2021-03-25 22:40:19* @LastEditors: Please set LastEditors* @LastEditTime: 2021-03-25 23:06:11*/
    #include <iostream>
    using namespace std;
    int ju1[1000][1000], ju2[1000][1000];
    int res[1000][1000];
    int main(void)
    {int ra, ca, rb, cb;cin >> ra >> ca;for (int i = 0; i < ra; i++){for (int j = 0; j < ca; j++){cin >> ju1[i][j];}}cin >> rb >> cb;for (int i = 0; i < rb; i++){for (int j = 0; j < cb; j++){cin >> ju2[i][j];}}if (ca != rb){cout << "Error: " << ca << " != " << rb << endl;system("pause");return 0;}else{cout << ra << " " << cb << endl;for (int i = 0; i < ra; i++){for (int j = 0; j < cb; j++)for (int k = 0; k < ca; k++)res[i][j] += ju1[i][k] * ju2[k][j];}for (int i = 0; i < ra; i++){for (int j = 0; j < cb - 1; j++)cout << res[i][j] << " ";cout << res[i][cb - 1] << endl;}}system("pause");return 0;
    }
    

团体程序设计天梯赛-练习集 L1-033——L1-048相关推荐

  1. 【CCCC】PAT : 团体程序设计天梯赛-练习集 L1 答案

    [CCCC]PAT : 团体程序设计天梯赛-练习集 L1 答案 鉴定完毕,全部水题 ヾ(•ω•`)o 标号 标题 分数 通过数 提交数 通过率 L1-001 Hello World 5 46779 1 ...

  2. 【CCCC】PAT : 团体程序设计天梯赛-练习集 L2 答案,题解,附代码

    [CCCC]PAT : 团体程序设计天梯赛-练习集 L2 答案 鉴定完毕,全部水题 ヾ(•ω•`)o 知识点分类(32): 1.树锯结构(9):二叉树的存储,编号,遍历顺序转换,求深度,底层节点,从底 ...

  3. 团体程序设计天梯赛练习集题解整合

    网上介绍 团体程序设计天梯赛练习集 的文章已经很多了, 我的这篇文章是对练习集题解的整合,方便每一位备战 团体程序设计天梯赛 的同学使用. 一年一度的 团体程序设计天梯赛 即将开始,PTA的练习集是必 ...

  4. 【CCCC】PAT : 团体程序设计天梯赛-练习集 L3 答案(01-23)

    [CCCC]PAT : 团体程序设计天梯赛-练习集 L3 答案 顶着满课,整整一星期,终于咕完了.(:´д`)ゞ 知识点分类(23): 1.搜索模拟(5):BFS,DFS,最短路,路径打印 2.计算几 ...

  5. PTA团体程序设计天梯赛-练习集(3)

    PTA团体程序设计天梯赛-练习集 L1-001 Hello World (5 分) 这道超级简单的题目没有任何输入. 你只需要在一行中输出著名短句"Hello World!"就可以 ...

  6. PTA团体程序设计天梯赛-练习集

    PTA团体程序设计天梯赛-练习集 L1-024 后天 L1-025 正整数A+B L1-026 I Love GPLT L1-027 出租 L1-029 是不是太胖了 L1-030 一帮一 L1-03 ...

  7. PTA团体程序设计天梯赛-练习集Level-1(参考代码C语言/Python版)

    本题目集截止到2022年天梯赛 受个人水平限制,<PTA团体程序设计天梯赛-练习集>中暂时只能把Level-1的题目做出来(也许有些Level-2的题可以写出来?)-我不是专门搞竞赛的,参 ...

  8. 团体程序设计天梯赛-练习集——L3-020 至多删三个字符

    给定一个全部由小写英文字母组成的字符串,允许你至多删掉其中 3 个字符,结果可能有多少种不同的字符串? 输入格式: 输入在一行中给出全部由小写英文字母组成的.长度在区间 [4, 106] 内的字符串. ...

  9. 团体程序设计天梯赛-练习集(L1)

    001:Hello World(5 分)(AC) 注意要点:无. #include<iostream> using namespace std;int main(){printf(&quo ...

最新文章

  1. Creational模式之Builder模式
  2. topcoder srm 330 div1
  3. php把网络图片转化为base64格式,解决html2canvas图片跨域问题
  4. python 3389爆破机
  5. 深度学习之利用TensorFlow实现简单的全连接层网络(MNIST数据集)
  6. 没有Hyper-V服务,WP Emulator无法启动
  7. 激光光凝后容易出现频繁闪光的原因
  8. 福建计算机及应用专业的大学,33所福建大学公布国家级/省级一流本科专业!
  9. 连锁行业信息化的现状与问题
  10. SPSS数据分析全套教程(1)——SPSS概览
  11. Qt Http下载器
  12. emmagee测试汇总
  13. instant-ngp总结
  14. 什么是MTTF、MTBF、MTTR
  15. java swing表格翻页_让Swing表格支持远程后台数据翻页
  16. iOS开发中extension的用法(延展)
  17. 七牛云被攻击偷跑流量
  18. 上海亚商投顾:沪指缩量反弹 新能源汽车产业链走强
  19. 记录oracle的一些操作
  20. Flowable入门系列文章62 - 异步延续

热门文章

  1. php 浮点减法,PHP.减去两个浮点数的结果
  2. 在Xcode中进行自动化测试
  3. ES6——符号Symbol
  4. 【UX31A 黑苹果bigsur优化篇-变频,亮度,USB定制】
  5. 记账小软件典型用户分析
  6. 相当经典的笑话,超级搞笑!(转贴)
  7. 今天的虚空龙日常任务
  8. mysql 事务的好坏_mysql存储引擎:InnoDB和MyISAM的差别/优劣评价/评测/性能测试
  9. 鼠标移入操作兄弟元素
  10. 韩式多用动态图(浪漫情侣)