Codeforces Round #209 (Div. 2)
A:
要么是两次要么4次,判断是否在边界;
#include<cstdio>
using namespace std; int main()
{
int n,m,x;
bool flag=;
scanf("%d%d",&n,&m);
for(int i=; i<n; i++)
for(int j=; j<m; j++)
{
scanf("%d",&x);
if(x==&&(i==||i==n-||j==||j==m-))
flag=;
}
if(flag)puts("");
else puts("");
return ;
}
B:
太简单了;
#include<cstdio>
using namespace std; int main()
{
int n,k;
scanf("%d%d",&n,&k);
for(int i=;i<=k;i++)
printf("%d %d ",i*,i*-);
for(int i=k+;i<=n;i++)
printf("%d %d ",i*-,i*);
return ;
}
C:
分子每个都是N-1项的,所以从他们的最小的那个开始;
如果有k的整数倍个,就把他们合成一个,然后找到最小的那个不能合成的;
#include<cstdio>
#include<map>
#include<iostream>
#define maxn 100005
#define ll long long
#define mod 1000000007
using namespace std;
ll d[maxn],sum;
ll num[maxn];
map<ll,ll>mp;
map<ll,ll>::iterator it; ll Pow(ll x,ll k)
{
if(k==)
return ;
if(k==)
return x;
ll c=Pow(x,k>>);
if(k&)
return ((c*(x%mod))%mod)*c%mod;
else
return c*c%mod;
} int main()
{
int n;
ll k,ans;
cin>>n>>k;
for(int i=; i<n; i++)
{
cin>>num[i];
sum+=num[i];
}
for(int i=; i<n; i++)
{
mp[sum-num[i]]++;
}
for(it=mp.begin(); it!=mp.end(); it++)
{
if(it->second)
{
if(it->second%k==)
mp[it->first+]+=it->second/k;
else
{
if(it->first<=sum)
ans=it->first;
else ans=sum;
break;
}
}
}
cout<<Pow(k,ans)<<endl;
return ;
}
Codeforces Round #209 (Div. 2)的更多相关文章
- Codeforces Round #209 (Div. 2) B. Permutation
解题思路: 如果序列a是单调递增的,则序列为1,2,..... 2n,则将给出的式子化简得Σ(a2i - a2i-1) = n 如果序列a是单调递减的,则序列为2n,.........2, 1,则将给 ...
- Codeforces Round #209 (Div. 2) A. Table
#include <iostream> #include <vector> using namespace std; int main(){ int n,m; cin > ...
- Codeforces Round #209 (Div. 2)C
刷了一页的WA ..终于发现了 哪里错了 快速幂模板里一个变量t居然开得long ... 虽然代码写的丑了点 但是是对的 那个该死的long 啊.. #include <iostream&g ...
- Codeforces Round #209 (Div. 2)A贪心 B思路 C思路+快速幂
A. Table time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...
- Codeforces Round #209 (Div. 2) D. Pair of Numbers (模拟)
D. Pair of Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #209 (Div. 2) C - Prime Number
传送门 题意 给出n个数及x,求 \[\frac{\sum _{i=1}^n x^{a_1+a_2+...+a_{i-1}+a_{i+1}+...a_n}}{\prod_{i=1}^n x^{a_i} ...
- 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 ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
随机推荐
- Spark Shuffle实现
Apache Spark探秘:Spark Shuffle实现 http://dongxicheng.org/framework-on-yarn/apache-spark-shuffle-details ...
- h2database源码浅析:事务、两阶段提交
Transaction Isolation Transaction isolation is provided for all data manipulation language (DML) sta ...
- 转:Unity3D的四种坐标系
World Space(世界坐标):我们在场景中添加物体(如:Cube),他们都是以世界坐标显示在场景中的.transform.position可以获得该位置坐标. Screen Space(屏幕坐标 ...
- 如何给windows窗体程序打包成一个安装包
http://blog.csdn.net/xyy410874116/article/details/6341787 给windows窗体程序打包成一个安装包:具体操作在:http://hi.baidu ...
- C#集合之ArrayList
C#中之所以有集合这个东东,是因为数组的长度是固定的,而实际需求是,不确定未来这个“数组”的个数,故出现集合这个概念,因为集合的容量会随元素的增加曾倍数增长.C#中有2类常用集合:ArrayList, ...
- java星座、年龄、日期等
星座: public static String getStar(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(dat ...
- JDBC向oracle插入数据
public static void main(String[] args) throws SQLException { 2 3 4 String driver="oracle.jdbc.d ...
- json转换(c#后台生成json的方法)
此文转自:http://bbs.csdn.net/topics/380200497,为了方便自己记忆才以文章形式保存. using System; using System.Collections.G ...
- makefile--Unfound symbol
Unfound symbol ,库函数的包含问题或者头文件包含问题 makefile对#的识别度太低了,如果使用了,#它之后的可能就不能识别了,然后会报错的Unfound symbol /////// ...
- 安装kali之后
更新源(以下设置均基于这些源) #vi /etc/apt/sources.list 把这些源加进去 ############################ debian wheezy ####### ...