Codeforces 525E Anya and Cubes】的更多相关文章

http://codeforces.com/contest/525/problem/E 题意: 有n个方块,上面写着一些自然数,还有k个感叹号可用.k<=n 你可以选任意个方块,然后选一些贴上感叹号使上面的数值变成阶乘,然后把方块上的值加起来会得到一个和. 求和等于S的选择方法数. 思路:折半搜索,然后把所有状态按权值排序,然后统计 #include<cstdio> #include<cmath> #include<algorithm> #include<c…
题目链接:点击打开链接 题意: 给定n个数.k个感叹号,常数S 以下给出这n个数. 目标: 随意给当中一些数变成阶乘.至多变k个. 再随意取一些数,使得这些数和恰好为S 问有多少方法. 思路: 三进制状压.中途查找. #include <stdio.h> #include <vector> #include <algorithm> #include <iostream> #include <cmath> #include <map>…
说的是给了n个立方体,立方体从1标号到n,每个立方体上有一个数字, 你有 k 个机会 使得其中 k个数位他们自己的阶乘,(自然使用可以少于k次机会,每个立方体最多被使用1次) ,那么求出你从这n个立方体重选出任意个立方体使得 他们的和为S n<25 可以知道直接使用n去枚举自然受不了, 我们将n个数字分为两部分来算,前面n/2个数字 我们枚举他们使用j次可以得到的数,然后后面的n-n/2个数再次使用这个方法,直接在dfs枚举的时候进行判断S-s 在前一个钟是否出现过,出现过就加起来. 分块处理…
Codeforces Round #297 (Div. 2)E. Anya and Cubes Time Limit: 2 Sec  Memory Limit: 512 MBSubmit: xxx  Solved: 2xx 题目连接 http://codeforces.com/contest/525/problem/E Description Anya loves to fold and stick. Today she decided to do just that. Anya has n c…
大意: 给定$n$元素序列$a$, 可以任选不超过$k$个$a_i$变换为$a_i!$, 求变换后任选若干元素和为S的方案数. 分成两块暴搜, 复杂度$O(3^{\frac{n}{2}})$ #include <iostream> #include <algorithm> #include <cstdio> #include <unordered_map> #define REP(i,a,n) for(int i=a;i<=n;++i) using n…
http://codeforces.com/contest/525/problem/E 学习了传说中的折半DFS/双向DFS 先搜前一半数,记录结果,然后再搜后一半数,匹配之前结果. #include<algorithm> #include<iostream> #include<cstring> #include<cstdio> #include<cmath> #include<map> #define LL long long us…
题目 Source http://codeforces.com/contest/525/problem/E Description Anya loves to fold and stick. Today she decided to do just that. Anya has n cubes lying in a line and numbered from 1 to n from left to right, with natural numbers written on them. She…
 Anya and Ghosts Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 508C Description Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts ton…
Anya loves to fold and stick. Today she decided to do just that. Anya has n cubes lying in a line and numbered from 1 to n from left to right, with natural numbers written on them. She also has k stickers with exclamation marks. We know that the numb…
C. Anya and Smartphone time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Anya has bought a new smartphone that uses Berdroid operating system. The smartphone menu has exactly n applications,…