先说C

题目链接:http://codeforces.com/problemset/problem/471/C

题目意思:有 n 张卡,问能做成多少种不同楼层(floor)的 house。注意这 n 张卡都要用光。每层 floor 都由一定的 room 构成,每两个相邻 room 规定要有一个公共的ceiling。规定从上到下看,每层 floor 的 room 的数量呈递增的形式排布。

这样的东西一般就是看图,先自己从小数開始推算找规律 能够发现第i层须要(3*i+2)个,那么前i层总的最少须要就是等差数列求和得(3*i+1)*i/2。  由于不能剩余。那么n-(3*i+1)*i/2必须能被3整除。那么从1到(3*i+1)*i/2<=n遍历一下即可 n=10^12  所以O(1e6)时间还是够的

//#pragma comment(linker, "/STACK:102400000,102400000")
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <queue>
using namespace std; #define ls(rt) rt*2
#define rs(rt) rt*2+1
#define ll long long
#define ull unsigned long long
#define rep(i,s,e) for(int i=s;i<e;i++)
#define repe(i,s,e) for(int i=s;i<=e;i++)
#define CL(a,b) memset(a,b,sizeof(a))
#define IN(s) freopen(s,"r",stdin)
#define OUT(s) freopen(s,"w",stdout)
const ll ll_INF = ((ull)(-1))>>1;
const double EPS = 1e-8;
const double pi = acos(-1.0);
const int INF = 100000000; int main()
{
ll n;
while(~scanf("%I64d",&n))
{
ll ans=0,tmp;
for(ll i=1;(tmp=(3*i+1)*i/2)<=n;i++)
{
if( ( n-tmp )%3 == 0)
ans++;
}
printf("%I64d\n",ans);
}
return 0;
}

B,  首先能不能出现三种以上的排列,写代码时用了类似离散化的写法,能的话  就随便改两个数的次序就能凑够3种

//#pragma comment(linker, "/STACK:102400000,102400000")
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <queue>
using namespace std; #define ls(rt) rt*2
#define rs(rt) rt*2+1
#define ll long long
#define ull unsigned long long
#define rep(i,s,e) for(int i=s;i<e;i++)
#define repe(i,s,e) for(int i=s;i<=e;i++)
#define CL(a,b) memset(a,b,sizeof(a))
#define IN(s) freopen(s,"r",stdin)
#define OUT(s) freopen(s,"w",stdout)
const ll ll_INF = ((ull)(-1))>>1;
const double EPS = 1e-8;
const double pi = acos(-1.0);
const int INF = 100000000; const int MAXN = 2000+20;
struct Node{
int id,v;
}p[MAXN];
int n;
bool cmp(Node a, Node b)
{
return a.v<b.v;
} void print()
{
printf("%d",p[1].id);
for(int i=2;i<=n;i++)
printf(" %d",p[i].id);
putchar('\n');
} void SW(Node &a, Node &b)
{
Node tmp;
tmp=a;
a=b;
b=tmp;
} int main()
{ while(~scanf("%d",&n))
{
for(int i=1;i<=n;i++)
{
scanf("%d",&p[i].v);
p[i].id=i;
}
sort(p+1,p+n+1,cmp);
p[n+1].v=-1;
int tmp=1,pre=p[1].v;
ll cnt=1;
int flag=0;
for(int i=2;i<=n+1;i++)
if(pre!=p[i].v)
{
if(tmp>=3){flag=1;break;}
cnt*=tmp;
if(cnt>=3){flag=1;break;}
tmp=1;
pre=p[i].v;
}
else
{
tmp++;
}
if(!flag)puts("NO");
else
{
puts("YES");
print();
int pr=p[1].v,tmp=1;
int cnt=1;
for(int i=2;i<=n+1;i++)///
if(pr!=p[i].v)
{
if(tmp==2)
{
SW(p[i-1],p[i-2]);
if(cnt<3)print(),cnt++;; }
if(tmp >= 3)
{
SW(p[i-1],p[i-2]);
if(cnt<3) print(),cnt++;
//cnt++;
SW(p[i-1],p[i-3]);
if(cnt<3)print(),cnt++;
//cnt++;
}
if(cnt >=3)break;
tmp=1;
pr=p[i].v;
}
else
{
tmp++;
}
}
}
return 0;
}

A  水  只是由于flag少写了一个 WA了一次

//#pragma comment(linker, "/STACK:102400000,102400000")
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <queue>
using namespace std; #define ls(rt) rt*2
#define rs(rt) rt*2+1
#define ll long long
#define ull unsigned long long
#define rep(i,s,e) for(int i=s;i<e;i++)
#define repe(i,s,e) for(int i=s;i<=e;i++)
#define CL(a,b) memset(a,b,sizeof(a))
#define IN(s) freopen(s,"r",stdin)
#define OUT(s) freopen(s,"w",stdout)
const ll ll_INF = ((ull)(-1))>>1;
const double EPS = 1e-8;
const double pi = acos(-1.0);
const int INF = 100000000; int len[10],vis[12]; int main()
{
while(~scanf("%d%d%d%d%d%d",len,len+1,len+2,len+3,len+4,len+5))
{
int ans=0;
CL(vis,0);
sort(len,len+6);
int cnt=0,flag=0;
for(int i=0;i<6;i++)
{
vis[len[i]]++;
if(vis[len[i]] == 4)cnt=i,flag=1;
}
if(vis[len[cnt]] == 5)
{
puts("Bear");
continue;
}
if(vis[len[cnt]] == 6)
{
puts("Elephant");
continue;
}
int last=-1,ff=0;
for(int i=0;i<6;i++)
if(i!=cnt)
{
if(vis[len[i]] == 2)ff=1;
if(last==-1){len[0]=len[i];last=1;}
else len[5]=len[i];
}
if(ff && flag)
{
puts("Elephant");
continue;
}
if(len[0]!=len[5] && flag)
{
puts("Bear");
continue;
}
if(len[0]==len[5] && flag)
{
puts("Elephant");
continue;
}
puts("Alien");
}
return 0;
}

Codeforces Round #269 (Div. 2) A B C的更多相关文章

  1. Codeforces Round #269 (Div. 2) A,B,C,D

    CodeForces - 471A 首先要有四个数相等,然后剩下两个数不同就是Bear,否则就是Elephant. #include <bits/stdc++.h> using names ...

  2. Codeforces Round #269 (Div. 2) D - MUH and Cube Walls kmp

    D - MUH and Cube Walls Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & % ...

  3. Codeforces Round #269 (Div. 2)

    A 题意:给出6根木棍,如果有4根相同,2根不同,则构成“bear”,如果剩余两个相同,则构成“elephant” 用一个数组分别储存各个数字出现的次数,再判断即可 注意hash[i]==5的时候,也 ...

  4. Codeforces Round #269 (Div. 2)-D. MUH and Cube Walls,KMP裸模板拿走!

    D. MUH and Cube Walls 说实话,这题看懂题意后秒出思路,和顺波说了一下是KMP,后来过了一会确定了思路他开始写我中途接了个电话,回来kaungbin模板一板子上去直接A了. 题意: ...

  5. Codeforces Round #269 (Div. 2) B. MUH and Important Things

    It's time polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from t ...

  6. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  7. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  8. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  9. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

随机推荐

  1. (转载)QT中PRO文件写法的详细介绍,很有用,很重要!

    版权声明:本文为博主原创文章,未经博主允许不得转载. 在QT中,有一个工具qmake可以生成一个makefile文件,它是由.pro文件生成而来的,.pro文件的写法如下: 1. 注释从“#”开始,到 ...

  2. How to retreive raw post data from HttpServletRequest in java

    public static String getPostData(HttpServletRequest req) { StringBuilder sb = new StringBuilder(); t ...

  3. C# - 使用 List<> 泛型给GridView控件数据

    创建实体模型: namespace Test.Models { public class Student { public string ID { get; set; } public string ...

  4. Transformations 方块转换

    题目是中文题,就不做什么解释了,纯模拟题,主要要搞清楚这几种装换方式下标的变化: 第一种:顺时针旋转90度: c[j][n-i+1]=a[i][j]; 第二种:旋转180度: c[n-i+1][n-j ...

  5. 14.6.7?Limits on InnoDB Tables InnoDB 表的限制

    14.6.7?Limits on InnoDB Tables InnoDB 表的限制 警告: 不要把MySQL system tables 从MyISAM 到InnoDB 表. 这是不支持的操作,如果 ...

  6. HDU 1556 Color the Ball 线段树 题解

    本题使用线段树自然能够,由于区间的问题. 这里比較难想的就是: 1 最后更新须要查询全部叶子节点的值,故此须要使用O(nlgn)时间效率更新全部点. 2 截取区间不能有半点差错.否则答案错误. 这两点 ...

  7. 让notepad.exe的utf8不添加BOM

    实在是厌烦了notepad的utf8模式了,于是决定修改之,方案如下: 使用任何支持hex模式的编辑器打开%SystemRoot%/system32/notepad.exe查找二进制串56 8D 45 ...

  8. 用VC制作应用程序启动画面

    摘 要:本文提供了四种启动画面制作方法. 使用启动画面一是可以减少等待程序加载过程中的枯燥感(尤其是一些大型程序):二是 可以用来显示软件名称和版权等提示信息.怎样使用VC++制作应用程序的启动画面呢 ...

  9. javascript (四) 改变html样式

    <h1 id="domo"> this is testing test</h1> <script> function changecolor() ...

  10. gulp多张图片自动合成雪碧图

    相信做前端的同学都做过这样的事情,为优化图片,减少请求会把拿到切好的图标图片,通过ps(或者其他工具)把图片合并到一张图里面,再通过css定位把对于的样式写出来引用的html里面.对于一些图片较多的项 ...