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 ...
随机推荐
- HDU 4336 Card Collector:状压 + 期望dp
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4336 题意: 有n种卡片(n <= 20). 对于每一包方便面,里面有卡片i的概率为p[i],可 ...
- enable nested VT in VM
问题描述: 处理器支持VT-x,并且已经在BIOS中开启了VT-x.在host os上用VMware Workstation安装了一个Ubuntu虚拟机,在虚拟机中执行“cat /proc/cpuin ...
- C#多线程编程介绍——使用thread、threadpool、timer
C#多线程编程介绍——使用thread.threadpool.timer 在system.threading 命名空间提供一些使得能进行多线程编程的类和接口,其中线程的创建有以下三种方法:thread ...
- poj 2719 Faulty Odometer
Description You are given a car odometer which displays the miles traveled as an integer. The odomet ...
- sublime插件insertDate显示ISO时间
1 下载insertDate插件以及安装完毕 2 把光标放在想插入ISO时间的地方 3 按住:alt+f5,之后,在sublime下面的Date format string输入:iso.之后按ente ...
- hdu3037Saving Beans——卢卡斯定理
题目:http://acm.hdu.edu.cn/showproblem.php?pid=3037 卢卡斯定理模板——大组合数的取模 代码如下: #include<iostream> #i ...
- 10 Vue 学习 shortList页面
1: shortList页面代码如下: <template> <div class="fillcontain"> <head-top></ ...
- linux 遍历目录+文件(优化版本)
c++17 filesystem, regex 遍历目录 #include <stdio.h> #include <sys/types.h> #include <dire ...
- java面向对象的三大特性
1.面向对象的三大特性 继承.封装.多态 什么是继承? ①继承是面向对象程序设计能够提高软件开发效率的重要原因之一. ②继承是具有传递性的,就像现实中孙子不仅长得像爸爸而且还像他爷爷. ③继承来的属性 ...
- SSAS IIS 发布
http://www.cnblogs.com/zhangzt/p/4046259.html IIS7下配置SSAS通过HTTP远程连接 淘宝 问答 学院 博客 资源下载 高端培训 ...