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”三种中任意一种就输 ...
随机推荐
- C#下解决DrawImage画出来的Image变大了的问题
如: private Image image= Resources.image1;//假设image1这张资源图是360×600这么大 private Graphics graphics; graph ...
- mysql查找重复
중복된 것 모두 찾기 SELECT 필드명, count(*) FROM 테이블명 GROUP BY 필드명 mysql> SELECT t1, count(*) FROM tes ...
- InvoiceCancelSendApAction
package nc.ui.pu.m25.action; import java.awt.event.ActionEvent; import nc.bs.framework.common.NCLoca ...
- 数据库笔试题(经典select语句的用法)【转载】
原文地址:数据库笔试题(经典select语句的用法)作者:lily 问题描述: 为管理岗位业务培训信息,建立3个表: S (S#,SN,SD,SA) S#,SN,SD,SA 分别代表学号.学员姓名.所 ...
- mysqld-nt: Out of memory (Needed 1677720 bytes)解决方法
http://www.jb51.net/article/58726.htm 今天发现网站有点慢,发现mysql日志中提示mysqld-nt: Out of memory (Needed 1677720 ...
- serialize
Jquery的serialize()方法用于将表单元素转换为查询字符串格式, Submit按钮及File选择元素是不能序列化的. $('input:button').click(function() ...
- GNU glibc
在线G-lib-c(GNU C Library库)网站 参考: 1.bitsToTypes
- Update files embedded inside CAB file.
References: https://community.flexerasoftware.com/showthread.php?182791-Replace-a-single-file-embedd ...
- 九度OJ 1511 从尾到头打印链表
题目地址:http://ac.jobdu.com/problem.php?pid=1511 题目描述: 输入一个链表,从尾到头打印链表每个节点的值. 输入: 每个输入文件仅包含一组测试样例. 每一组测 ...
- CSS3之渐变效果
在css3出来之前,想要出现渐变效果必须就要制作一张图片.不过css3的出现使得渐变效果变得简单.由于不是所有的浏览器都支持css3,所以不是所有的浏览器都能够呈现出css3的效果出来.因此目前大部分 ...