SRM484
又Orz了一发rng_58。。
250pt:
题意:给定一种兔子数:当S(x*x) = S(x)*S(x)时,x为兔子数,其中S(x)表示各个数位之和。
思路:本来想了一个复杂度很高的想法。。然后想看一下是否正确时,才知道是是找规律。。原来规律就是x的每一位只可能是0-3.所以直接枚举即可。。
code:
#line 7 "RabbitNumber.cpp"
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std; #define PB push_back
#define MP make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<double> VD;
typedef long long LL;
typedef pair<int,int> PII; class RabbitNumber
{
public:
int L, R;
set<int> S1;
int S(long long x){
int res = ;
for (;x;) res += x % , x /= ;
return res;
}
void dfs(int number, int k){
if (k == ){
if (number < L || number > R) return;
if (number && S(number) * S(number) == S((long long)(number) * number)) S1.insert(number);
return;
}
for (int i = ; i <= ; ++i) dfs(number * + i, k + );
}
int theCount(int low, int high)
{
L = low;
R = high;
S1.clear();
if (high == ) S1.insert(R);
dfs(, );
return (int)S1.size();
} };
500pt
题意:一个堆栈,每次往里面扔一个气球(气球有四种颜色,可任意选一个放进去),每次当栈顶有L<=10个气球的时候,这L个将会破掉。问往里面扔N<=1000后并且最后栈为空的方案数
思路:想了好久还是不会做。。不过思路确实不难。
dp[i][j]表示放了i个气球,并且还需要j个气球可使栈为空的方案数。
那么,如果当前j为0,不管放什么颜色都还需要L-1个球来消掉。
如果j不为0,有两种情况,一种放跟栈顶颜色一样,则j-1,否者j+L-1
code:
// BEGIN CUT HERE
/* */
// END CUT HERE
#line 7 "PuyoPuyo.cpp"
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std; #define PB push_back
#define MP make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define fep(i,n) for(int i=0;i<=(n);++i)
#define M 1000000007
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<double> VD;
typedef long long LL;
typedef pair<int,int> PII;
int dp[][]; class PuyoPuyo
{
public:
int theCount(int L, int N)
{
memset(dp, , sizeof(dp));
dp[][] = ;
rep(i, N) fep(j, N) if (dp[i][j]){
if (j) dp[i+][j-] = (dp[i+][j-] + dp[i][j]) % M;
else dp[i+][L-] = (dp[i+][L-] + ((long long)dp[i][j] * ) % M) % M;
if (j && j + L - <= N)
dp[i+][j + L - ] = (dp[i+][j + L - ] + ((long long)dp[i][j] * ) % M) % M;
}
return dp[N][];
}
};
SRM484的更多相关文章
随机推荐
- Iperf使用方法与参数说明
Iperf使用方法与参数说明 http://pkgs.repoforge.org/iperf/ Iperf是一个网络性能测试工具.可以测试TCP和UDP带宽质量,可以测量最大TCP带宽,具有多种参 ...
- Python爬虫的原理
简单来说互联网是由一个个站点和网络设备组成的大网,我们通过浏览器访问站点,站点把HTML.JS.CSS代码返回给浏览器,这些代码经过浏览器解析.渲染,将丰富多彩的网页呈现我们眼前: 一.爬虫是什么? ...
- xgboost安装
安装连接:https://www.zhihu.com/question/46377605 软件连接:https://www.lfd.uci.edu/~gohlke/pythonlibs/#xgboos ...
- 之前的一些Oracle的经验总结
1. 安装: 1) 关于字符集的选择,现在还不很了解,修改是需要进入一个模式下才可以修改,当然新建一个数据库实例的时候可以重新设定: UTF8是相对比较大的一个字符集, 可以简单实用这个就能保存很多的 ...
- 【转载】 了解实时媒体的播放(RTP/RTCP 和 RTSP)
http://blog.csdn.net/span76/article/details/12913307 离线媒体只是用 Http协议去读取服务器端文件而已,而对于实时直播如何实现, 这里就要用到 R ...
- 记录一次JVM调优【GC日志的分析】
首先查看服务器版本默认信息: 修改tomcat/bin/catalina.sh,在最顶端加入JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCDetails -Xloggc ...
- [C#.net]处理UTF-8文件乱码
今天帮同事处理一个2M左右的文件的格式,发现使用Encoding.default & Encoding.UTF8 & Encoding.GetEncoding("GB2312 ...
- Android Camera后台拍照
http://item.congci.com/item/android-camera-houtai-paizhao 有许多人希望在不让用户知道的情况下,使用Android后台Service调用摄像头拍 ...
- neo4j服务配置
第一步: 首先下载neo4j的community版本的 https://neo4j.com/download-center/ 第二步-添加环境变量: NEO4J_HOME = [文件路径] Pa ...
- 如何将mysql卸载干净
一.在控制面板中卸载mysql软件 二.卸载过后删除C:\Program Files (x86)\MySQL该目录下剩余了所有文件,把mysql文件夹也删了 三.windows+R运行“regedit ...