AtCoder Beginner Contest 071 ABCD
1001
求个绝对值比较大小喽
1002
把字符串出现的字母记录一下,然后遍历a-z,谁第一个没出现就输出谁
1003
Problem Statement
We have N sticks with negligible thickness. The length of the i-th stick is Ai.
Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.
Constraints
- 4≤N≤105
- 1≤Ai≤109
- Ai is an integer.
Input
Input is given from Standard Input in the following format:
N
A1 A2 ... AN
Output
Print the maximum possible area of the rectangle. If no rectangle can be formed, print 0.
题意:选出四个点能组成矩形,且面积最大
解法:选4个一样的点或者是选两个出现两次以上的最大数字
#include<bits/stdc++.h>
using namespace std;
map<int,int>Mp,mp,ap;
int n;
long long A[];
int ans;
int main(){
long long x=,y=;
int flag1=,flag2=;
scanf("%d",&n);
for(int i=;i<=n;i++){
cin>>A[i];
Mp[A[i]]++;
}
sort(A+,A++n);
for(int i=n;i>=;i--){
if(Mp[A[i]]>=&&mp[A[i]]==){
mp[A[i]]=;
x*=A[i];
ans++;
}
if(ans==){
flag1=;
break;
}
}
for(int i=n;i>=;i--){
if(Mp[A[i]]>=){
y*=(A[i]*A[i]);
flag2=;
break;
}
}
if(flag1||flag2){
cout<<max(x,y)<<endl;
}else{
cout<<""<<endl;
}
return ;
}
Problem Statement
We have a board with a 2×N grid. Snuke covered the board with N dominoes without overlaps. Here, a domino can cover a 1×2 or 2×1 square.
Then, Snuke decided to paint these dominoes using three colors: red, cyan and green. Two dominoes that are adjacent by side should be painted by different colors. Here, it is not always necessary to use all three colors.
Find the number of such ways to paint the dominoes, modulo 1000000007.
The arrangement of the dominoes is given to you as two strings S1 and S2 in the following manner:
- Each domino is represented by a different English letter (lowercase or uppercase).
- The j-th character in Si represents the domino that occupies the square at the i-th row from the top and j-th column from the left.
Constraints
- 1≤N≤52
- |S1|=|S2|=N
- S1 and S2 consist of lowercase and uppercase English letters.
- S1 and S2 represent a valid arrangement of dominoes.
Input
Input is given from Standard Input in the following format:
N
S1
S2
Output
Print the number of such ways to paint the dominoes, modulo 1000000007.
Sample Input 1
3
aab
ccb
Sample Output 1
6
There are six ways as shown below:
Sample Input 2
1
Z
Z
Sample Output 2
3
Note that it is not always necessary to use all the colors.
Sample Input 3
52
RvvttdWIyyPPQFFZZssffEEkkaSSDKqcibbeYrhAljCCGGJppHHn
RLLwwdWIxxNNQUUXXVVMMooBBaggDKqcimmeYrhAljOOTTJuuzzn
Sample Output 3
958681902
解法:把上面的图染色,且相邻的颜色不同
解法:
1. 原来没有
aa
aa这种情况,就说嘛,想了好久
2.
第一次出现的是横还是竖
横 *6
竖 *3
出现横时,上一次出现的是
横 *3
竖 *2
出现竖时,上一次出现的是
横 *1
竖 *2
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <map>
#define int long long using namespace std; const int mod=; char str[][]; signed main()
{
int n;
scanf("%lld",&n);
for(int i=; i<; i++)
{
scanf("%s",str[i]);
}
bool flag=false;
int f=;
int t=;
for(int i=; i<n; i++)
{
if(str[][i]==str[][i+])
{
if(f==)
{
t*=;
t*=;
f=;
}
else
{
if(flag)
{
t*=;
t*=;
}
else
{
t*=;
}
}
flag=false;
i++;
}
else
{
if(str[][i]==str[][i])
{
if(f==)
{
t*=;
f=;
}
else
{
if(flag) t*=;
else t*=;
}
flag=true;
}
}
t%=mod;
}
cout<<t<<endl;
return ;
}
AtCoder Beginner Contest 071 ABCD的更多相关文章
- AtCoder Beginner Contest 053 ABCD题
A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...
- AtCoder Beginner Contest 068 ABCD题
A - ABCxxx Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement This contes ...
- AtCoder Beginner Contest 070 ABCD题
题目链接:http://abc070.contest.atcoder.jp/assignments A - Palindromic Number Time limit : 2sec / Memory ...
- AtCoder Beginner Contest 069 ABCD题
题目链接:http://abc069.contest.atcoder.jp/assignments A - K-City Time limit : 2sec / Memory limit : 256M ...
- AtCoder Beginner Contest 057 ABCD题
A - Remaining Time Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Dol ...
- AtCoder Beginner Contest 051 ABCD题
A - Haiku Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement As a New Yea ...
- AtCoder Beginner Contest 052 ABCD题
A - Two Rectangles Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement The ...
- AtCoder Beginner Contest 071 D - Coloring Dominoes
Problem Statement We have a board with a 2×N grid. Snuke covered the board with N dominoes without o ...
- AtCoder Beginner Contest 054 ABCD题
A - One Card Poker Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Ali ...
随机推荐
- BZOJ 3400 [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队:dp【和为f的倍数】
题目链接:http://begin.lydsy.com/JudgeOnline/problem.php?id=1375 题意: 给你n个数,你可以从中选任意多个,但不能不选.问你所选数字之和为f的倍数 ...
- 揭秘FaceBook Puma演变及发展——FaceBook公司的实时数据分析平台是建立在Hadoop 和Hive的基础之上,这个根能立稳吗?hive又是sql的Map reduce任务拆分,底层还是依赖hbase和hdfs存储
在12月2日下午的“大数据技术与应用”分论坛的第一场演讲中,来自全球知名互联网公司——FaceBook公司的软件工程师.研发经理邵铮就带来了一颗重磅炸弹,他将为我们讲解FaceBook公司的实时数据处 ...
- bjwc Day3 & 4 妈妈我这是来了个什么地方呀
真·bjwc开始了 Day3 T1啥啥啥 第k大斜率?想都没想码了个暴力,然后爆零...暴力都能错,退役 T2看着像网络流就扔了个网络流大暴力上去,六七十分的样子然后蜜汁wa T3题面说“想都没想就弄 ...
- 如何卸载ubuntu软件
你的硬盘空间已经不太足够了?如果你使用的是Ubuntu操作系统,你可能想知道如何能够卸载过时.无用的程序.有几种方法可以卸载程序,包括图形化方法和命令行方法.参考本指南,采用最适合你的方法卸载程序. ...
- AIM Tech Round 4 (Div. 2)
A题 分析:暴力 #include "iostream" #include "cstdio" #include "cstring" #inc ...
- Cache系列:spring-cache简单三步快速应用ehcache3.x-jcache缓存(spring4.x)
前言:本项目基于spring4.x构建,使用ehcache3.5.2和JCache(jsr107规范) 一.依赖 除了ehcache和cache-api外,注意引用spring-context-sup ...
- BZOJ2329:[HNOI2011]括号修复
浅谈\(splay\):https://www.cnblogs.com/AKMer/p/9979592.html 浅谈\(fhq\)_\(treap\):https://www.cnblogs.com ...
- DS:目录
ylbtech-DS:目录 1.返回顶部 2.返回顶部 3.返回顶部 4.返回顶部 5.返回顶部 6.返回顶部 作者:ylbtech出处:http://ylbtech.cn ...
- Excel解析easyexcel工具类
Excel解析easyexcel工具类 easyexcel解决POI解析Excel出现OOM <!-- https://mvnrepository.com/artifact/com.alibab ...
- 你所不知道的html5与html中的那些事(三)
文章简介: 关于html5相信大家早已经耳熟能详,但是他真正的意义在具体的开发中会有什么作用呢?相对于html,他又有怎样的新的定义与新理念在里面呢?为什么一些专家认为html5完全完成后,所有的工作 ...