摘要: 我的方式是用暴力的方法找到每一行每一列的边界点;但是有大神直接用一个公式解决了:floor(n*sqrt(2))*4;想了很久还是不理解,求各路大神指点!#include#include#includeusing namespace std;int main(){ long long n; cin>>n; if(n==0){cout1) ans+=pre-cur-1; pre=cur; } ans--; cout<<ans*4;}View Code 阅读全文
posted @ 2014-02-19 23:23 Yours1103 阅读(237) 评论(0) 推荐(0) 编辑
摘要: 详解见:http://blog.csdn.net/tri_integral/article/details/18666797#include#include#define maxn 105#includeusing namespace std;int s[maxn];int main(){ int n; int tmp; while(scanf("%d",&n)!=EOF) { memset(s,0,sizeof s); s[50]=n; bool flag; while(1) { ... 阅读全文
posted @ 2014-02-19 12:42 Yours1103 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 概率dp,有点像背包的做法;dp[i][j]代表前i个数组成的j数的概率为多少#include#include#define maxn 40009using namespace std;double dp[45][maxn];int s;double sco;int main(){ int t,n; scanf("%d",&t); while(t--) { memset(dp,0,sizeof dp); dp[0][0]=1; scanf("%d%lf",&n,&sco); for(int i=0;i=sco) ... 阅读全文
posted @ 2014-02-19 08:27 Yours1103 阅读(182) 评论(0) 推荐(0) 编辑