
OnlineJudge
望君持之以恒
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
[PAT] 2020年春季赛题目 完整题目 + 完整答案 + 个人总结
[PAT] 2020年春季赛题目 完整题目这次比赛在2020/07/25日举行, 距离比赛截止前5分钟.100分的人数有: 86人90分到99分的有: 142人7-1 Prime Day (20分)The above picture is from Sina Weibo, showing May 23rd, 2019 as a very cool "Prime Day". That is, not only that the corresponding number of the d.原创 2020-07-25 22:49:06 · 2210 阅读 · 2 评论 -
算法笔记 栈 中缀转后缀表达式 codeup 1918 简单计算器
#include <iostream>#include <string>#include <stack>#include <queue>#include <map>using namespace std;struct node{ double num; //操作数 char op; //操作符 bool flag; //true表示操作数, false表示操作符};string str;st.原创 2020-07-11 17:02:51 · 250 阅读 · 0 评论 -
1039 Course List for Student 使用map超时, unordered_map能过
1039 Course List for Student使用map超时, unordered_map是能够通过的.在unordered_map下使用str.resize(4); scanf("%s", &str[0]);在unordered_map下使用cin>>str的时间:正确代码:#include <iostream>#include <unordered_map>#include <vector>#inc..原创 2020-07-10 21:11:04 · 424 阅读 · 0 评论 -
1096 Consecutive Factors 样例三 测试点三 无法通过
1096Consecutive Factors(20分)Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be factored as 3×5×6×7, where 5, 6, and 7 are the three consecutive numbers. Now given any positive N, you are ..原创 2020-07-10 15:32:58 · 548 阅读 · 0 评论 -
PAT乙级 1049 数列的片段和 (20分) PAT甲级 1104 Sum of Number Segments (20分)
我过不了啊....还是萌新的我怎么也想不到还会有精度问题....————————————————版权声明:本文为优快云博主「冰释的温存」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。原文链接:https://blog.youkuaiyun.com/qq_21394327/article/details/1069750161049 数列的片段和 (20分)给定一个正数数列,我们可以从中截取任意的连续的几个数,称为片段。例如,给定数列 { 0.1, 0.2, 0.转载 2020-07-08 17:34:45 · 225 阅读 · 0 评论 -
B1019/A1069 数字黑洞 借用string, algorithm快速完成
通过大量库函数快速完成此题.比如 sort对字符串排序string.length()来对不足4位的数字补0to_string()将string快速转为int(还有个astox函数可以实现string.c_str()快速转数字)掌握一些库函数有利于快速做题#include <iostream>#include <algorithm>#include <string>using namespace std;int str2num(stri原创 2020-07-08 16:47:28 · 1025 阅读 · 0 评论 -
1067 Sort with Swap(0, i) 使用Map 36行 短代码
和PAT书上的思路不一样。我使用了map,费内存是真的。但是换来了运行时间。使用map的思路是这样的。原来用数组,下标里面存值。用map则是key是值,value是原来数组的下标,即map<值,下标>这样就O(1)访问了。#include<map>#include<iostream>#include<algorithm>using namespace std;int main(){ int n; scanf("原创 2020-06-30 21:17:33 · 181 阅读 · 0 评论 -
简单易懂 PAT 1033 To Fill or Not to Fill 贪心算法
取消注释, 看跑路过程!贪心思路:1. 优先前往油价比当前油价更低的油站,为了前往这个油站,油箱里的油要加最少(即跑到下一站油量恰好为0),为了能去那里加更便宜的油2. 没有比当前油价低的油站时,则在能跑到的油站里寻找价格最低的油站,但是这个最低的油站也比当前油站的价格高,所以要在当前油站把油加满。3. 如果满油都到不了任意一个油站,那就说明到不了目的地,最远到达当前油站坐标+满油箱能跑的距离#include <iostream>#include <al..原创 2020-06-29 09:48:25 · 235 阅读 · 0 评论 -
PAT 1016 Phone Bills 简单易懂 C++
1016Phone Bills代码简单易懂. 觉得算法笔记书上的代码过于复杂了.#define _CRT_SECURE_NO_WARNINGS#include <iostream>#include <algorithm>#include <cstring>struct Cus{ char name[21]; int month;...原创 2020-05-04 12:13:12 · 279 阅读 · 0 评论 -
codeup 1817 Problem B A+B
#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>int main(){ char ch1; int i=0; int a[2]={0,0}; int flag[2]={1,1}; int enterflag = 0; while(scanf("%c",&ch...原创 2019-12-22 11:28:01 · 213 阅读 · 0 评论 -
Leetcode 292. Nim 游戏
该题十分简单. 仔细分析题意即可你和你的朋友,两个人一起玩Nim 游戏:桌子上有一堆石头,每次你们轮流拿掉1 - 3 块石头。 拿掉最后一块石头的人就是获胜者。你作为先手。你们是聪明人,每一步都是最优解。 编写一个函数,来判断你是否可以在给定石头数量的情况下赢得游戏。示例:输入: 4输出: false 解释: 如果堆中有 4 块石头,那么你永远不会赢得比赛; ...原创 2019-05-12 16:42:19 · 255 阅读 · 0 评论 -
Leetcode 第136场周赛 5055 困于环中的机器人
在无限的平面上,机器人最初位于(0, 0)处,面朝北方。机器人可以接受下列三条指令之一:"G":直走 1 个单位 "L":左转 90 度 "R":右转 90 度机器人按顺序执行指令instructions,并一直重复它们。只有在平面中存在环使得机器人永远无法离开时,返回true。否则,返回false。class Solution {public: bool ...原创 2019-05-12 16:36:54 · 365 阅读 · 0 评论 -
Leetcode 第133场周赛 1029 两地调度
结束了春招面试以后, 发现自己笔试能力太弱.毕竟连阿里的面试官都说: 你项目经历倒是很丰富, 但是基础能力太弱.自己开始在Leetcode上刷题, 不过最近一直都在做链表的题目...也是心血来潮报名了Leetcode的第133场周赛.截止到目前我只看了第一题和最后一题.考试期间一道题都没做出来.还要加油!!!!!原题:公司计划面试2N人。第i人飞往A...原创 2019-04-21 21:29:04 · 537 阅读 · 0 评论 -
PTA乙级1004【成绩排名】代码
#include <iostream>using namespace std;struct Student{ string name; string number; int score;};int main(){ int n; cin>>n; Student *s = new Student[n]; i...原创 2019-04-07 10:11:26 · 435 阅读 · 0 评论 -
PTA乙级1002【写出这个数】代码
我写的代码:#include <iostream>#include <math.h>using namespace std;int main(){ char a; int sum=0; string b[10]={"ling","yi","er","san","si","wu","liu","qi","ba","jiu"}; w...原创 2019-04-06 00:52:09 · 283 阅读 · 0 评论