摘要: 开关问题满足的条件: 最优解情况下,一个开关只按一次 开关的顺序无关 由于数据范围比较小,可以直接枚举出所有开关情况(0~2^16 - 1),然后操作一下灯泡,然后检查一下是不是全开开了即可,注意最后答案要求字典序最小的步数最少的解。 之所以从0~2^16枚举是因为后面一个数中包含的1的个数一定>= 阅读全文
posted @ 2020-08-07 13:50 yys_c 阅读(128) 评论(0) 推荐(0) 编辑
摘要: 100可以表示为带分数的形式:100=3+69258/714还可以表示为:100=82+3546/197. 注意特征:带分数中,数字 1∼9分别出现且只出现一次(不包含 0)。类似这样的带分数,100有 11种表示法。 输入格式 一个正整数。 输出格式 输出输入数字用数码 1∼9不重复不遗漏地组成带 阅读全文
posted @ 2020-08-05 13:58 yys_c 阅读(245) 评论(0) 推荐(0) 编辑
摘要: Problem Description Fat brother and Maze are playing a kind of special (hentai) game on an N*M board (N rows, M columns). At the beginning, each grid 阅读全文
posted @ 2020-08-04 15:14 yys_c 阅读(321) 评论(0) 推荐(0) 编辑
摘要: 高精加 #include<iostream> #include<vector> #include<algorithm> using namespace std; int check(vector<int> &a){ int l = 0, r = a.size() - 1; while(l < r){ 阅读全文
posted @ 2020-08-03 22:32 yys_c 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 5 * 5 方阵,二进制枚举第一行的开关情况,后一行的开关情况由上一行的灯的亮暗情况决定,最后特判一下最后一行。所有开关次数取最小值,最后检查一下开关次数是否大于6就行了。 #include<iostream> #include<cstring> using namespace std; const 阅读全文
posted @ 2020-08-03 21:50 yys_c 阅读(144) 评论(0) 推荐(0) 编辑
摘要: Description Farmer John knows that an intellectually satisfied cow is a happy cow who will give more milk. He has arranged a brainy activity for cows 阅读全文
posted @ 2020-08-03 21:31 yys_c 阅读(84) 评论(0) 推荐(0) 编辑
摘要: Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 2469135 阅读全文
posted @ 2020-08-03 18:06 yys_c 阅读(138) 评论(0) 推荐(0) 编辑
摘要: A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years 阅读全文
posted @ 2020-08-02 22:10 yys_c 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 输入n,输出「1~n」的幂集。 位运算 #include<iostream> using namespace std; int n; void dfs(int u, int k){ if(u == n){ for(int i = 0; i < u; i ++) if(k >> i & 1) cout 阅读全文
posted @ 2020-08-02 13:54 yys_c 阅读(113) 评论(0) 推荐(0) 编辑
摘要: A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supposed to find the 阅读全文
posted @ 2020-08-02 09:53 yys_c 阅读(121) 评论(0) 推荐(0) 编辑