
CCF
ccf
知之之
这个作者很懒,什么都没留下…
展开
-
得分30 的二十四点,不知哪里错了
#include <iostream>#include <stack>//#define debugusing namespace std;stack<int> res;stack<char> op;int main(){ int n,i,j,a = 0,b = 0,d = 0,tmp; //char c[8]; string c; cin >> n; for(i = 0;i < n;i++)原创 2020-05-11 17:05:35 · 144 阅读 · 1 评论 -
CCF201903-1 小中大
/***这题挺坑的。首先四舍五入基本上不用考虑,直接%.1f就行了。其次计算flout时,注意强制转换int为flout再计算。如 flout mid = (a + b)/2;这mid算出来永远是整数应写为flout mid = (a + b)/2.0**/#include <iostream>#include <stdio.h>//#define debugusing namespace std;int main(){ int n,i,a =原创 2020-05-11 16:00:37 · 172 阅读 · 0 评论 -
201912-1小明种苹果(续)V2.0
/***和上题一样,都是一行一行地处理,所以不用像上次提交那样先声明4M的数组。但是这个lost标记数组是必须的,不过也相当小,总耗内存也就500KB。**/#include <iostream>//#define debugusing namespace std;bool lost[1007];int main(){ int n,m,i,j,T = 0,D = 0, E = 0,sum,tmp; cin >> n; for(i = 0;i &原创 2020-05-11 15:24:17 · 106 阅读 · 0 评论 -
201909-1小明种苹果
/**800+ms很长,不知为何。**/#include <iostream>//#define debugusing namespace std;int main(){ int n,m,i,j,T = 0,k = 0, p = 0,sum,tmp,beg; cin >> n >> m; for(i = 0;i < n;i++){ sum = 0; cin >> beg; for(j = 0;j原创 2020-05-11 15:12:10 · 185 阅读 · 0 评论 -
201912-1报数
#include <iostream>//#define debugusing namespace std;int a[4] = {0};int main(){ int n,i,j; cin >> n; for(i = 0,j = 1; i < n;++j){ if(j % 7 == 0 || j % 10 == 7 || (j / 10) % 10 == 7|| (j / 100 ) % 10 == 7){ ++a[(j原创 2020-05-11 14:42:07 · 199 阅读 · 0 评论 -
CCF(2019-12月)回收站选址
/**值得纪念,一次通过,还用了STL**/#include <iostream>#include <map>#include<vector>//#define debugusing namespace std;int a[4] = {0};struct Node{int x,y;int score;bool flag;};map<int, vector<struct Node> > m;vector <原创 2020-05-11 13:44:47 · 184 阅读 · 0 评论 -
201912-1小明种苹果(续)V1.0
/**D的更新错误导致一直50分。D是掉落苹果的棵树,我一开始更新写在判断每一次掉落的地方了,如果同一颗苹果掉落多次,D会相应增加多次所以一直50分。排错30分钟。**/#include <iostream>//#define debugusing namespace std;typedef long long ll;ll a[1003][1003];bool bad[1003];int main(){ ll n,m,T = 0,D = 0,E = 0,i原创 2020-05-11 13:01:49 · 127 阅读 · 0 评论 -
201812-2 小明放学
/***得60分原因:int不够,用long long才行。也参考了大佬的做法,我最初得分20的做法被注释掉了,就是else里的那部分。得20 是因为取模运算后加1了**/#include <iostream>#include <algorithm>//#define debugusing namespace std;typedef long long ll;int main(){ ll n,x,z,r,y,g,res = 0,cur = 0,lig原创 2020-05-08 19:24:04 · 97 阅读 · 0 评论 -
CCF201903-2 二十四点
/***根据表达式求值双栈算法编写。不是最简方法。思路:map用于存储符号优先级,s是符号栈,res是操作数栈计算函数写的很不好,重复代码很多遇到了坑**/#include <iostream>#include <algorithm>#include <map>#include<stack>//#define debugusi...原创 2020-05-07 20:23:27 · 167 阅读 · 0 评论 -
CCF201803-2 碰撞的小球
/***参考大佬的做法:dir用1和-1 表示,然后创新是pos + dir这句更新坐标的语句总的做法是 先更新坐标,再遍历检查需要改变方向的两种情况遇到了坑,写if语句忘了加括号**/#include <iostream>#include <algorithm>//#define debugusing namespace std;struct Nod...原创 2020-05-07 17:55:33 · 144 阅读 · 0 评论 -
CCF201809-2 买菜
/***学习的大佬的方法:区间调度之交集问题。**/#include <iostream>#include <algorithm>//#define debugusing namespace std;struct Node{ int s; int e; bool operator < (Node & node)cons...原创 2020-05-06 23:34:13 · 103 阅读 · 0 评论 -
小中大
#include <iostream>#include <algorithm>#include <stdio.h>#include <math.h>//#define debugusing namespace std;int a[100007];int main(){ int n,i,k; cin >> n...原创 2020-05-06 22:20:54 · 136 阅读 · 0 评论 -
约瑟夫环递归
#include <iostream>using namespace std;int josephus(int n, int m) { if(n == 1) return 0; else return ( josephus(n-1,m)+m ) % n;} int main() { int n, m; cin >> n >> m; int...转载 2020-05-05 12:49:54 · 125 阅读 · 0 评论 -
CCF201712-2 游戏
#include <iostream>#include <algorithm>//#define debugusing namespace std;struct node{ struct node * next; int id;};int main(){ int n,k,i; node * head, *tail,*p, ...原创 2020-05-05 11:56:48 · 142 阅读 · 0 评论 -
CCF 201709-2 公共钥匙盒
#include <iostream>#include <algorithm>//#define debugusing namespace std;class Node{ public: int start; int flag; int key; bool operator <(Node & node)con...原创 2020-05-04 22:42:44 · 127 阅读 · 0 评论 -
素因数
#include <iostream>using namespace std;int main(){ int m,k,res; void f(int); cin >> m; f(m); cout << endl; return 0;}void f (int n){ bool prime(int i);...原创 2020-05-04 20:32:23 · 205 阅读 · 0 评论 -
C++vector及new学习记录
#include <iostream>#include <algorithm>#include <vector>using namespace std;int main(){ vector<int> v; v = * new vector<int>(20,8);//new返回的同JAVA一样的地址 ...原创 2020-05-02 21:51:26 · 2356 阅读 · 2 评论 -
CCF201703-2 学生排队
#include <iostream>#include <algorithm>#define N 1001using namespace std;int main(){ int n,m,i,j,k,x,y,tmp; cin >> n >> m; int q[1002]; for(i = 1;i <...原创 2020-05-02 19:34:04 · 146 阅读 · 0 评论 -
CCF201604-2 俄罗斯方块
#include <iostream>using namespace std;#define ROW 15#define COL 10#define N 4int board[ROW + 1][COL];int block[N][N];struct cord{ int x,y;}cor[N];int main(){ int i,j,col...原创 2020-05-01 11:27:41 · 158 阅读 · 0 评论 -
CCF201512-2 消除类游戏
#include <iostream>using namespace std;const int N = 31;int a[N][N];int f(int a){return a > 0 ? -a:a;}int main(){ int n,m,i,j,k,tmp; int f(int); cin >> n >>...原创 2020-04-30 22:04:01 · 140 阅读 · 0 评论 -
CCF日期计算
#include <iostream>using namespace std;const int N = 10001;int a[N];int monttArray[13]={0,31,28,31,30,31, 30,31,31,30,31, 30,31};int main(){ int y,d,mon = 0,day = 0; cin >>...原创 2020-04-30 21:45:58 · 172 阅读 · 0 评论 -
CCF201503-2 数字排序
#include <iostream>#include<algorithm>#include<map>using namespace std; const int N = 1001; struct Num{ int val; int cnt; bool operator<(const Num &a )const{...原创 2020-04-30 21:26:08 · 135 阅读 · 0 评论 -
CCF201312-1 出现次数最多的数
#include <iostream>using namespace std;const int N = 10001;int a[N];int main(){int n, res = 0, max = 0,tmp;cin >> n;while(n--){cin >> tmp;a[tmp]++;max = max > tmp ? m...原创 2020-04-30 13:04:35 · 185 阅读 · 0 评论 -
CCF201409-2 画图
#include <iostream>using namespace std;const int N = 100;int a[N][N];int main(){ int n,res = 0,x1,y1,x2,y2,i,j; cin >> n; while(n--){ cin >> x1 >>...原创 2020-04-30 12:22:04 · 153 阅读 · 0 评论 -
CCF201409-1 相邻数对
c++中 #includec++中 #include<algorithm>是包含了排序算法的,sort(a, a+n)这样#include <iostream>#include <algorithm>using namespace std;const int N = 10001;int a[N];int main(){ int...原创 2020-04-30 12:08:55 · 93 阅读 · 0 评论 -
CCF201403-2 窗口
#include <iostream>using namespace std;const int N = 1001;int a[N];struct Win{int x1,x2,y1,y2;}win[10];int lev[11];int main(){ int n,m,i,j,k,x,y,index; cin >> n>&g...原创 2020-04-30 11:47:12 · 94 阅读 · 0 评论 -
CCF201403-1 相反数
#include <iostream>using namespace std;const int N = 1001;int a[N];int main(){ int n,res = 0,tmp; cin >> n; while(n--){ cin >> tmp; tmp = tmp &g...原创 2020-04-30 10:50:12 · 152 阅读 · 0 评论 -
CCF201312-2 ISBN号码
#include <iostream>using namespace std;const int N = 101;int a[N];int main(){ char c[20],ch; int sum = 0; cin >> c; for(int i = 0,j = 1;i < 11;i++)//写错了一次,写成...原创 2020-04-30 10:44:57 · 101 阅读 · 0 评论 -
CCF201503-2 数字排序
类实现Comparable<> 接口并重写compareTo(T) 方法就可以排序。Iterator<Entry<Integer,Integer>> it=m.entrySet().iterator()其中m是HashhMap类型原创 2020-04-20 16:05:34 · 84 阅读 · 1 评论 -
CCF201412-2 Z字形扫描
方法一:很长:#include <iostream>using namespace std;const int N = 1000;int a[N];int main(){ int n,m,res = 0,i,j,tmp,x,y; n = 4; int aa[n][n] = { {1,5 ,3 ,9},{3, 7 ,5 ,6},{9,4 ,6 ,4},...原创 2020-04-17 14:45:10 · 107 阅读 · 0 评论 -
CCF201403-2 窗口
看了一位大佬的思路,记录一下优先级的技巧:用一个额外的pri[n]数组来指向优先级为角标的窗口。如pri[0] = 2代表优先级为0 的窗口号是2。这样,在改变优先级的时候,只改一下pri数组的数字即可。#include <iostream>using namespace std;const int N = 1000;int a[N];struct Win{ in...原创 2020-04-17 13:46:25 · 141 阅读 · 0 评论 -
C++ get 和getline
https://www.jb51.net/article/158128.htm原创 2020-04-17 11:14:12 · 211 阅读 · 0 评论 -
CCF201412-2 Z字形扫描
样例输入41 5 3 93 7 5 69 4 6 47 3 1 3样例输出1 5 3 9 7 3 9 5 4 7 3 6 6 4 1 3看成2*(n - 1)个斜线的遍历。分别都是斜着的遍历。原创 2020-04-14 16:23:45 · 109 阅读 · 0 评论 -
CCF201412-2 Z字形扫描
样例输入41 5 3 93 7 5 69 4 6 47 3 1 3样例输出1 5 3 9 7 3 9 5 4 7 3 6 6 4 1 3看成2*(n - 1)个斜线的遍历。分别都是斜着的遍历。原创 2020-04-10 10:48:49 · 107 阅读 · 0 评论 -
CCF201409-3 字符串匹配
string.h函数:char *strcat(char *dest, const char *src)把 src 所指向的字符串追加到 dest 所指向的字符串的结尾。char *strcpy(char *dest, const char *src)把 src 所指向的字符串复制到 dest。char *strchr(const char *str, int c)在参数 str 所指...原创 2020-04-09 21:43:07 · 193 阅读 · 0 评论 -
CCF 命令行选项
char *strtok(char *str, const char *delim) 分解字符串 str 为一组字符串,delim 为分隔符。该函数返回被分解的第一个子字符串,如果没有可检索的字符串,则返回一个空指针。...原创 2020-04-09 18:55:07 · 143 阅读 · 0 评论